Class: Tag

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/scoped_tags/tag.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_or_new_by_name_and_context(name, context) ⇒ Object



12
13
14
15
# File 'lib/scoped_tags/tag.rb', line 12

def self.find_or_new_by_name_and_context(name, context)
  tag = self.find(:first, :conditions => ["name = ? and context = ?", name, context])
  tag || Tag.new(:name => name, :context => context)
end

Instance Method Details

#==(object) ⇒ Object



17
18
19
# File 'lib/scoped_tags/tag.rb', line 17

def ==(object)
  super || (object.is_a?(Tag) && self.name == object.name && self.context == object.context)
end