From 1c466a362509867617cb4e5bddebd7b95de69ba0 Mon Sep 17 00:00:00 2001 From: ccocchi Date: Wed, 25 Jul 2012 22:53:09 +0200 Subject: [PATCH] Underscore private instance variable @options to avoid conflicts with view variables --- lib/rabl-rails/renderers/base.rb | 6 +++--- lib/rabl-rails/renderers/json.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rabl-rails/renderers/base.rb b/lib/rabl-rails/renderers/base.rb index e053a19..00c85d7 100644 --- a/lib/rabl-rails/renderers/base.rb +++ b/lib/rabl-rails/renderers/base.rb @@ -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 diff --git a/lib/rabl-rails/renderers/json.rb b/lib/rabl-rails/renderers/json.rb index ef42fb5..632aaec 100644 --- a/lib/rabl-rails/renderers/json.rb +++ b/lib/rabl-rails/renderers/json.rb @@ -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