lib/gon.rb in gon-4.0.2 vs lib/gon.rb in gon-4.0.3

- old
+ new

@@ -42,28 +42,36 @@ def set_variable(name, value) Request.gon[name] = value end + def push(data = {}) + raise "Object must have each_pair method" unless data.respond_to? :each_pair + + data.each_pair do |name, value| + set_variable(name.to_s, value) + end + end + def all_variables Request.gon end def clear Request.clear end def rabl(*args) - unless Gon.constants.include?(:Rabl) + unless Gon.constants.map(&:to_sym).include?(:Rabl) raise "Possible wrong require order problem - try to add `gem 'rabl'` before `gem 'gon'` in your Gemfile" end data, options = Gon::Rabl.handler(args) store_builder_data 'rabl', data, options end def jbuilder(*args) - unless Gon.constants.include?(:Jbuilder) + unless Gon.constants.map(&:to_sym).include?(:Jbuilder) raise "Possible wrong require order problem - try to add `gem 'jbuilder'` before `gem 'gon'` in your Gemfile" end data, options = Gon::Jbuilder.handler(args) store_builder_data 'jbuilder', data, options