Class: Tag

Inherits:
Object show all
Defined in:
lib/glue/taggable.rb

Overview

The default Tag implementation. A tag attaches semantics to a given object. – FIXME: use index and char() instead of String. ++

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Tag

Returns a new instance of Tag.



18
19
20
21
# File 'lib/glue/taggable.rb', line 18

def initialize(name = nil)
  @name = name
  @count = 0
end

Class Method Details

.total_frequency(tags = Tag.all) ⇒ Object

Helper method



41
42
43
# File 'lib/glue/taggable.rb', line 41

def self.total_frequency(tags = Tag.all)
  tags.inject(1) { |total, t| total += t.count }
end

Instance Method Details

#tag(obj) ⇒ Object

– FIXME: use update_properties here! ++



27
28
29
30
31
# File 'lib/glue/taggable.rb', line 27

def tag(obj)
  send(obj.class.name.underscore.pluralize.to_sym) << obj
  @count += 1
  save!
end

#taggedObject

Return all tagged objects from all categories.



35
36
37
# File 'lib/glue/taggable.rb', line 35

def tagged
  # TODO.  
end