Module: Noah::Taggable
- Included in:
- Application, Configuration, Ephemeral, Host, Service, Token
- Defined in:
- lib/noah/taggable.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#tag!(tag_name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/noah/taggable.rb', line 7 def tag!(tag_name) case tag_name.class.to_s when "Array" tag_name.each do |t| my_tag = ::Noah::Tag.find_or_create(:name => t) << my_tag my_tag.members = self end else my_tag = ::Noah::Tag.find_or_create(:name => tag_name) << my_tag my_tag.members = self end self.save end |
#to_hash ⇒ Object
35 36 37 38 39 |
# File 'lib/noah/taggable.rb', line 35 def to_hash tag_arr = Array.new self..sort.each {|t| tag_arr << t.name} if self..size != 0 super.merge(:tags => tag_arr) end |
#untag!(tag_name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/noah/taggable.rb', line 23 def untag!(tag_name) case tag_name.class.to_s when "Array" tag_name.each do |t| remove_tag(t) end else remove_tag(tag_name) end self.save end |