Underscore private instance variable @options
to avoid conflicts with view variables
This commit is contained in:
parent
0034e05486
commit
1c466a3625
|
@ -3,11 +3,11 @@ module RablRails
|
||||||
class PartialError < StandardError; end
|
class PartialError < StandardError; end
|
||||||
|
|
||||||
class Base
|
class Base
|
||||||
attr_accessor :options
|
attr_accessor :_options
|
||||||
|
|
||||||
def initialize(context) # :nodoc:
|
def initialize(context) # :nodoc:
|
||||||
@_context = context
|
@_context = context
|
||||||
@options = {}
|
@_options = {}
|
||||||
setup_render_context
|
setup_render_context
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module RablRails
|
||||||
collection_or_resource = instance_variable_get(template.data) if template.data
|
collection_or_resource = instance_variable_get(template.data) if template.data
|
||||||
output_hash = collection_or_resource.respond_to?(:each) ? render_collection(collection_or_resource, template.source) :
|
output_hash = collection_or_resource.respond_to?(:each) ? render_collection(collection_or_resource, template.source) :
|
||||||
render_resource(collection_or_resource, template.source)
|
render_resource(collection_or_resource, template.source)
|
||||||
options[:root_name] = template.root_name
|
_options[:root_name] = template.root_name
|
||||||
format_output(output_hash)
|
format_output(output_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ module RablRails
|
||||||
module Renderers
|
module Renderers
|
||||||
class JSON < Base
|
class JSON < Base
|
||||||
def format_output(hash)
|
def format_output(hash)
|
||||||
hash = { options[:root_name] => hash } if options[:root_name] && RablRails.include_json_root
|
hash = { _options[:root_name] => hash } if _options[:root_name] && RablRails.include_json_root
|
||||||
MultiJson.encode(hash)
|
MultiJson.encode(hash)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue