Howto: Add my own functionality to a plugin?

The plugin in this case is acts_as_taggable_on_steroid, which has
classes Tag, Tagging and TagList, and a module
ActiveRecord::Acts::Taggable which adds the acts_as_taggable method to
all classes (so that when the call it they have some other modules
included at the class and instance level, giving them the acts as
taggable methods).

I have some extra methods i want to add to the Tag class and also to to
taggable classes. But, i can’t work out how to set this up in such a
way as my additional Tag methods sit on top of the exisiting Tag
methods, for example.

There must be a standard procedure for this situation - can anyone help
me out? (i’m guessing the best practise isn’t to physically add my own
methods into the plugin’s classes/modules)

Thanks
max

The plugin has this structure for the acts_as_taggable methods -

module ActiveRecord #:nodoc:
module Acts #:nodoc:
module Taggable #:nodoc:
def self.included(base)
base.extend(ClassMethods)
end

  module ClassMethods
    def acts_as_taggable
      has_many :taggings, :as => :taggable, :dependent => :destroy,

:include => :tag
has_many :tags, :through => :taggings

      before_save :save_cached_tag_list

      after_create :save_tags
      after_update :save_tags

      include ActiveRecord::Acts::Taggable::InstanceMethods
      extend ActiveRecord::Acts::Taggable::SingletonMethods

      alias_method_chain :reload, :tag_list
    end

    ...
  end

  module SingletonMethods
    ...
  end

  module InstanceMethods
    ...
  end
end

end
end

ActiveRecord::Base.send(:include, ActiveRecord::Acts::Taggable)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs