Module: MakeTaggable::Taggable::Related::ClassMethods

Defined in:
lib/make_taggable/taggable/related.rb

Overview

Added to every taggable model.

Instance Method Summary collapse

Instance Method Details

This method returns an undefined value.

Defines find_related_<context> and find_related_<context>_for for each context.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/make_taggable/taggable/related.rb', line 31

def initialize_make_taggable_related
  tag_types.map(&:to_s).each do |tag_type|
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def find_related_#{tag_type}(options = {})
        related_tags_for('#{tag_type}', self.class, options)
      end
      alias_method :find_related_on_#{tag_type}, :find_related_#{tag_type}

      def find_related_#{tag_type}_for(klass, options = {})
        related_tags_for('#{tag_type}', klass, options)
      end
    RUBY
  end
end

#make_taggable(*args) ⇒ void

This method returns an undefined value.

Adds contexts and refreshes the related-record finders.

Parameters:

  • args (Array<Symbol, String>)

    the contexts to add



52
53
54
55
# File 'lib/make_taggable/taggable/related.rb', line 52

def make_taggable(*args)
  super
  initialize_make_taggable_related
end