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 Base
|
||||
attr_accessor :options
|
||||
attr_accessor :_options
|
||||
|
||||
def initialize(context) # :nodoc:
|
||||
@_context = context
|
||||
@options = {}
|
||||
@_options = {}
|
||||
setup_render_context
|
||||
end
|
||||
|
||||
@ -21,7 +21,7 @@ module RablRails
|
||||
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) :
|
||||
render_resource(collection_or_resource, template.source)
|
||||
options[:root_name] = template.root_name
|
||||
_options[:root_name] = template.root_name
|
||||
format_output(output_hash)
|
||||
end
|
||||
|
||||
|
@ -2,7 +2,7 @@ module RablRails
|
||||
module Renderers
|
||||
class JSON < Base
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user