Class: Taglish::Tagging

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Util
Defined in:
lib/taglish/tagging.rb

Instance Method Summary collapse

Instance Method Details

#==(object) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/taglish/tagging.rb', line 30

def ==(object)
  super || (
    object.is_a?(Tagging) &&
    context == object.context &&
    name == object.name &&
    score == object.score)
end

#nameObject



21
22
23
# File 'lib/taglish/tagging.rb', line 21

def name
  @name ||= tag.name
end

#name=(v) ⇒ Object



25
26
27
28
# File 'lib/taglish/tagging.rb', line 25

def name=(v)
  raise "Can't change the name of a tag/tagging" if @name or (tag and tag.name)
  @name = v
end

#tag_typeObject

after_destroy :remove_unused_tags



17
18
19
# File 'lib/taglish/tagging.rb', line 17

def tag_type
  @tag_type ||= taggable.tag_types[context]
end

#to_sObject



38
39
40
# File 'lib/taglish/tagging.rb', line 38

def to_s
  score ? "#{name}:#{score}" : name
end