Module: DataMapper::Tags::SingletonMethods

Defined in:
lib/dm-tags/dm_tags.rb

Instance Method Summary collapse

Instance Method Details

#taggable?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dm-tags/dm_tags.rb', line 16

def taggable?
  true
end

#tagged_with(string, options = {}) ⇒ Object

Class Methods



6
7
8
9
10
11
12
13
14
# File 'lib/dm-tags/dm_tags.rb', line 6

def tagged_with(string, options = {})
  tag = Tag.first(:name => string)
  conditions = {
    'taggings.tag_id'        => tag.kind_of?(Tag) ? tag.id : nil,
    'taggings.taggable_type' => self,
  }
  conditions['taggings.tag_context'] = options.delete(:on) if options.key?(:on)
  all(conditions.update(options))
end