Skip to content
Browse files

Use to_hash in rabl engine to avoid parsing

Minor breakage: rabl will skip the root then
  • Loading branch information...
1 parent 655d02b commit 7da4c95bc141e0f014ee3a9e565487ee5098cf03 @skade skade committed Jan 11, 2012
Showing with 4 additions and 6 deletions.
  1. +2 −4 lib/gon/sinatra/rabl.rb
  2. +2 −2 spec/gon/gon_spec.rb
View
6 lib/gon/sinatra/rabl.rb
@@ -1,15 +1,13 @@
require 'rabl'
-require 'json'
module Gon
module Sinatra
module Rabl
class << self
def parse_rabl(rabl_path, controller)
source = File.read(rabl_path)
- rabl_engine = ::Rabl::Engine.new(source, :format => 'json')
- output = rabl_engine.render(controller, {})
- JSON.parse(output)
+ rabl_engine = ::Rabl::Engine.new(source, :format => 'hash')
+ rabl_engine.render(controller, {})
end
end
end
View
4 spec/gon/gon_spec.rb
@@ -64,8 +64,8 @@ def app
it 'render json from rabl template' do
@gon.clear
@objects = [1,2]
- Gon::Sinatra.rabl 'spec/test_data/sample.rabl', :instance => self
- Gon::Sinatra.objects.length.should == 2
+ @gon.rabl 'spec/test_data/sample.rabl', :instance => self, :as => 'objects'
+ @gon.objects.length.should == 2
end
def request

0 comments on commit 7da4c95

Please sign in to comment.
Something went wrong with that request. Please try again.