diff --git a/README.rdoc b/README.rdoc index cc3ef28..5dce0c4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -76,18 +76,6 @@ Make your model(s) that can follow other models acts_as_follower ... end -Extended setup: - # config/initializers/acts_as_follower.rb - - # By default list of parent classes includes only `[ApplicationRecord, ActiveRecord::Base]`. - ActsAsFollower.custom_parent_classes = [CustomRecord] - - # OR - - ActsAsFollower.setup do |c| - c.custom_parent_classes = [...] - end - --- === acts_as_follower methods diff --git a/lib/acts_as_follower.rb b/lib/acts_as_follower.rb index 1789c04..c9246b2 100644 --- a/lib/acts_as_follower.rb +++ b/lib/acts_as_follower.rb @@ -6,25 +6,5 @@ module ActsAsFollower autoload :FollowerLib, 'acts_as_follower/follower_lib' autoload :FollowScopes, 'acts_as_follower/follow_scopes' - def self.setup - @configuration ||= Configuration.new - yield @configuration if block_given? - end - - def self.method_missing(method_name, *args, &block) - @configuration.respond_to?(method_name) ? - @configuration.send(method_name, *args, &block) : super - end - - class Configuration - attr_accessor :custom_parent_classes - - def initialize - @custom_parent_classes = [] - end - end - - setup - require 'acts_as_follower/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3 end diff --git a/lib/acts_as_follower/follower_lib.rb b/lib/acts_as_follower/follower_lib.rb index 7c7a3f6..57c1a90 100644 --- a/lib/acts_as_follower/follower_lib.rb +++ b/lib/acts_as_follower/follower_lib.rb @@ -3,14 +3,9 @@ module FollowerLib private - DEFAULT_PARENTS = [ApplicationRecord, ActiveRecord::Base] - # Retrieves the parent class name if using STI. def parent_class_name(obj) - unless parent_classes.include?(obj.class.superclass) - return obj.class.base_class.name - end - obj.class.name + obj.class.base_class.name end def apply_options_to_scope(scope, options = {}) @@ -32,10 +27,5 @@ def apply_options_to_scope(scope, options = {}) scope end - def parent_classes - return DEFAULT_PARENTS unless ActsAsFollower.custom_parent_classes - - ActsAsFollower.custom_parent_classes + DEFAULT_PARENTS - end end end diff --git a/test/follow_test.rb b/test/follow_test.rb index 5100b27..2f99749 100644 --- a/test/follow_test.rb +++ b/test/follow_test.rb @@ -7,55 +7,4 @@ def test_assert_true_should_be_true assert true end - context "configuration with setters" do - should "contain custom parents" do - ActsAsFollower.custom_parent_classes = [CustomRecord] - - assert_equal [CustomRecord], ActsAsFollower.custom_parent_classes - end - end - - context "#setup" do - should "contain custom parents via setup" do - ActsAsFollower.setup do |c| - c.custom_parent_classes = [CustomRecord] - end - - assert_equal [CustomRecord], ActsAsFollower.custom_parent_classes - end - end - - context "with custom parents" do - setup do - @daddy = FactoryGirl.create(:daddy) - @mommy = FactoryGirl.create(:mommy) - @oasis = FactoryGirl.create(:oasis) - @metallica = FactoryGirl.create(:metallica) - end - - should "be followed" do - ActsAsFollower.custom_parent_classes = [CustomRecord] - - @daddy.follow(@mommy) - @daddy.follow(@metallica) - @mommy.follow(@oasis) - assert_equal true, @daddy.following?(@mommy) - assert_equal false, @mommy.following?(@daddy) - assert_equal true, @mommy.followed_by?(@daddy) - assert_equal false, @daddy.followed_by?(@mommy) - assert_equal true, @metallica.followed_by?(@daddy) - assert_equal true, @oasis.followed_by?(@mommy) - assert_equal true, @daddy.following?(@metallica) - assert_equal true, @mommy.following?(@oasis) - end - - should "be not followed" do - ActsAsFollower.custom_parent_classes = [] - - @daddy.follow(@mommy) - @mommy.follow(@oasis) - assert_equal false, @daddy.following?(@mommy) - assert_equal false, @mommy.following?(@oasis) - end - end end