Module: Mongoid::Tag::Meta::ClassMethods

Defined in:
lib/mongoid_tag/meta.rb

Instance Method Summary collapse

Instance Method Details

#tagmeta_for(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mongoid_tag/meta.rb', line 12

def tagmeta_for(*args)
  field_name = (args.blank? ? :tags : args.shift).to_sym

  class_eval %(
    def #{field_name}_with_weight
      get_weights_for(:#{field_name})
    end

    def #{field_name}_with_meta
      get_meta_for(:#{field_name})
    end

    def add_#{field_name.to_s.chop.to_sym}(tag, meta={})
      add_meta_tag(:#{field_name}, tag, meta)
    end
  )
end