Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions lib/acts_as_follower.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +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)
if method_name == :custom_parent_classes=
ActiveSupport::Deprecation.warn("Setting custom parent classes is deprecated and will be removed in future versions.")
end
@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
13 changes: 1 addition & 12 deletions lib/acts_as_follower/follower_lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand All @@ -32,11 +27,5 @@ def apply_options_to_scope(scope, options = {})
scope
end

def parent_classes
return DEFAULT_PARENTS unless ActsAsFollower.custom_parent_classes

ActiveSupport::Deprecation.warn("Setting custom parent classes is deprecated and will be removed in future versions.")
ActsAsFollower.custom_parent_classes + DEFAULT_PARENTS
end
end
end
9 changes: 0 additions & 9 deletions test/factories/somes.rb

This file was deleted.

18 changes: 0 additions & 18 deletions test/follow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +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

end