Underscore private instance variable @options

to avoid conflicts with view variables
This commit is contained in:
ccocchi 2012-07-25 22:53:09 +02:00
parent 0034e05486
commit 1c466a3625
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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