Permalink
Browse files

Allow subclasses to override the tag_list methods

  • Loading branch information...
1 parent 62f5fea commit 15ee3933e922c0801241b05fd0717a5a2f753530 @jdelStrother committed Oct 11, 2012
@@ -14,6 +14,7 @@ def self.included(base)
module ClassMethods
def initialize_acts_as_taggable_on_core
+ include taggable_mixin
tag_types.map(&:to_s).each do |tags_type|
tag_type = tags_type.to_s.singularize
context_taggings = "#{tag_type}_taggings".to_sym
@@ -36,7 +37,7 @@ def initialize_acts_as_taggable_on_core
:order => taggings_order
end
- class_eval %(
+ taggable_mixin.class_eval %(
def #{tag_type}_list
tag_list_on('#{tags_type}')
end
@@ -189,6 +190,10 @@ def adjust_taggings_alias(taggings_alias)
end
taggings_alias
end
+
+ def taggable_mixin
+ @taggable_mixin ||= Module.new
+ end
end
module InstanceMethods
@@ -538,6 +538,12 @@
@taggable.changes.should == {}
end
end
+
+ describe "Autogenerated methods" do
+ it "should be overridable" do
+ TaggableModel.create(:tag_list=>'woo').tag_list_submethod_called.should be_true
+ end
+ end
end
View
@@ -4,6 +4,12 @@ class TaggableModel < ActiveRecord::Base
acts_as_taggable_on :skills
acts_as_taggable_on :needs, :offerings
has_many :untaggable_models
+
+ attr_reader :tag_list_submethod_called
+ def tag_list=v
+ @tag_list_submethod_called = true
+ super
+ end
end
class CachedModel < ActiveRecord::Base

0 comments on commit 15ee393

Please sign in to comment.