Skip to content

Commit

Permalink
Fix bug with gon clear with global variables, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
gazay committed Jun 2, 2012
1 parent 8af0ac1 commit 147b3b5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,13 @@ Thats it!
Puts this line into `Gemfile` then run `$ bundle`:

``` ruby
gem 'gon', '3.0.3'
gem 'gon', '3.0.4'
```

Or if you are old-school Rails 2 developer put this into `config/environment.rb` and run `$ rake gems:install`:

``` ruby
config.gem 'gon', :version => '3.0.3'
config.gem 'gon', :version => '3.0.4'
```

Or manually install gon gem: `$ gem install gon`
Expand Down
4 changes: 2 additions & 2 deletions lib/gon/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module Base
class << self

def render_data(options)
data = Gon.all_variables || {}
if Gon.global.all_variables.present?
Gon::Request.gon['global'] = Gon.global.all_variables
data[:global] = Gon.global.all_variables
end
data = Gon.all_variables
namespace = options[:namespace] || 'gon'
need_tag = options[:need_tag].nil? || options[:need_tag]
start = "#{need_tag ? '<script>' : ''}window.#{namespace} = {};"
Expand Down
2 changes: 1 addition & 1 deletion lib/gon/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def gon
end

def clear
@request_env['gon'] = {}
env && (env[:gon] = {})
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/gon/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Gon
VERSION = '3.0.3'
VERSION = '3.0.4'
end
2 changes: 2 additions & 0 deletions spec/gon/global_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

before(:each) do
Gon::Global.clear
Gon::Request.instance_variable_set(:@request_env, nil)
end

describe '#all_variables' do
Expand Down Expand Up @@ -52,6 +53,7 @@
it 'outputs correct js with an integer and integer in Gon' do
Gon::Request.
instance_variable_set(:@request_id, request.object_id)
Gon::Request.env = {}
Gon.int = 1
Gon.global.int = 1
@base.include_gon.should == "<script>window.gon = {};" +
Expand Down

0 comments on commit 147b3b5

Please sign in to comment.