File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,6 @@ Gem::Specification.new do |s|
2020 s . require_paths = [ "lib" ]
2121 s . add_dependency "actionpack" , '>= 2.3.0'
2222 s . add_dependency "rabl"
23- s . add_dependency "yajl-ruby "
23+ s . add_dependency "json "
2424 s . add_development_dependency "rspec"
2525end
Original file line number Diff line number Diff line change @@ -44,10 +44,16 @@ def set_variable(name, value)
4444 end
4545
4646 def rabl ( view_path , options = { } )
47- # if rabl_name = options[:as] || options[:to]
48-
49- # end
50- set_variable ( 'rabl' , Gon ::Rabl . parse_rabl ( view_path , @request_env [ 'action_controller.instance' ] ) )
47+ rabl_data = Gon ::Rabl . parse_rabl ( view_path , @request_env [ 'action_controller.instance' ] )
48+ if options [ :as ]
49+ set_variable ( options [ :as ] . to_s , rabl_data )
50+ elsif rabl_data . is_a? Hash
51+ rabl_data . each do |key , value |
52+ set_variable ( key , value )
53+ end
54+ else
55+ set_variable ( 'rabl' , rabl_data )
56+ end
5157 end
5258 end
5359end
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ def parse_rabl(rabl_path, controller)
66 source = File . read ( rabl_path )
77 rabl_engine = Rabl ::Engine . new ( source , :format => 'json' )
88 output = rabl_engine . render ( controller , { } )
9-
9+ JSON . parse ( output )
1010 end
1111 end
1212end
You can’t perform that action at this time.
0 commit comments