Skip to content

Commit

Permalink
Fixed regression introduced in PR rails#39.
Browse files Browse the repository at this point in the history
- Also added test so it won't happen again.
- Added bundler config to fix insecure git protocol warnings.
- Removed a couple of unneeded deps.

Resolves rails#45
Resolves rails#49
  • Loading branch information
mvastola committed Feb 3, 2017
1 parent 34eae3b commit de8d9c5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_GITHUB__HTTPS: "true"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.gem
*.rbc
.bundle
.bundle/*
!.bundle/config
.config
.yardoc
Gemfile.lock
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in active_record-observers.gemspec
gemspec
gem 'rails', github: 'rails/rails', branch: '5-0-stable'
gem 'activeresource', github: 'rails/activeresource'
gem 'activeresource', github: 'rails/activeresource', branch: 'master'

gem 'mocha', require: false
21 changes: 17 additions & 4 deletions lib/rails/observers/active_model/observing.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
require 'set'
require 'singleton'
require 'rails/observers/active_model/observer_array'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/module/remove_method'
require 'active_support/core_ext/string/inflections'
require 'active_support/core_ext/enumerable'
require 'active_support/core_ext/object/try'
require 'active_support/descendants_tracker'

Expand All @@ -12,8 +11,22 @@ module ActiveModel
module Observing
extend ActiveSupport::Concern

def self.inclusions
@inclusions ||= Set.new
@inclusions.dup.freeze
end

def self.add_inclusion(klass)
@inclusions ||= Set.new << klass
end

included do
extend ActiveSupport::DescendantsTracker
extend ::ActiveSupport::DescendantsTracker
::ActiveModel::Observing.add_inclusion(self)
def self.inherited(subclass)
super
(::ActiveModel::Observing.inclusions & self.ancestors).each(&:instantiate_observers)
end
end

module ClassMethods
Expand Down Expand Up @@ -74,7 +87,7 @@ def observers
#
# Foo.observer_instances # => [#<FooObserver:0x007fc212c40820>]
def observer_instances
@observer_instances ||= []
@observer_instances ||= Set.new
end

# Instantiate the global observers.
Expand Down

0 comments on commit de8d9c5

Please sign in to comment.