surrounded-rails 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b83e69bd8d28d7e2df4c7881e88f79b5b899e96c
4
- data.tar.gz: 2cc02c359ad460ce4be15eff737eda4a60dbde57
3
+ metadata.gz: 2ddba4fbc6d5f185b51731509d819c8089bf890e
4
+ data.tar.gz: a25c583ad1000c758cbbbd364e9cfe18e145767b
5
5
  SHA512:
6
- metadata.gz: 2c0ba7c30c05bd610695791d20e076ed37333ba36211c1c9c410f5d519d273ca1019cdaf67531ef87ddfe09ec32705ff0b9c1e54c03b9b799bfb931918c9a67f
7
- data.tar.gz: f6c2baee92e962b53ad17f618944110892dc044913793ac22eff43c77d1298c1a27db07a09aa73175e2d7c7f7b86f8e9d720d88b029226cd3859c32a47c3b10c
6
+ metadata.gz: 935633344a9e91c7c2e88deafb26b7538d8caad8c0a5ae9f8baaade06e0db0f0504282d86273a7284f4162447404cd468861df41811acc263ff1c7c9e719b744
7
+ data.tar.gz: eb6ff1ac36e6dcae64263afdbf772735e2312aaf9c440ba0211455c9ae957f0372ca32eac5af3eacffc280652530a26b3991a45b934f425a327d63683ea43861
@@ -1,5 +1,5 @@
1
1
  module Surrounded
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -6,21 +6,18 @@ module Surrounded
6
6
  initializer 'surrounded.active_record' do |app|
7
7
  ActiveRecord::Base.send(:include, ::Surrounded)
8
8
  ActiveRecord::Base.class_eval {
9
- # Ideally this should hook into the initialization process
10
- # and set the @__surroundings__ collection there.
11
- # Currently I haven't found a way to do that.
12
- #
13
- # Surrounded uses respond_to_missing? and method_missing
14
- # which are two methods used when an ActiveRecord object
15
- # is initialized.
16
- #
17
- # The after_initialize callback happens after those methods
18
- # are used.
19
- #
20
- define_method(:surroundings){
21
- @__surroundings__ ||= []
22
- }
23
- private :surroundings
9
+ # This relies on a private method (present in Rails 3 and 4)
10
+ # because there is no earlier hook to set this variable.
11
+ # The after_initialize callback occurs to late because
12
+ # the initialize method has a procedure which calls
13
+ # respond_to? and Surrounded adds respond_to_missing?
14
+ # to get information from the context (which is the first
15
+ # item in the @__surroundings__ collection).
16
+ def init_internals_with_surrounded
17
+ Surrounded.create_surroundings(self)
18
+ init_internals_without_surrounded
19
+ end
20
+ alias_method_chain :init_internals, :surrounded
24
21
  }
25
22
  end
26
23
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "surrounded", "~> 0.3.1"
21
+ spec.add_dependency "surrounded", "~> 0.4.0"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surrounded-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - '''Jim Gay'''
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.1
19
+ version: 0.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.1
26
+ version: 0.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement