Class: Taggata::Persistent::Tag
- Defined in:
- lib/taggata/persistent/tag.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #file_tags ⇒ Object
- #files ⇒ Object
-
#initialize(db, name, id = nil) ⇒ Tag
constructor
A new instance of Tag.
- #to_hash ⇒ Object
Methods inherited from Abstract
bulk_insert, destroy, #destroy, find, find_one, find_or_create, #invalidate_cache, #save, #show
Constructor Details
#initialize(db, name, id = nil) ⇒ Tag
Returns a new instance of Tag.
7 8 9 10 11 |
# File 'lib/taggata/persistent/tag.rb', line 7 def initialize(db, name, id = nil) @db = db @name = name @id = id end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
5 6 7 |
# File 'lib/taggata/persistent/tag.rb', line 5 def db @db end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/taggata/persistent/tag.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/taggata/persistent/tag.rb', line 5 def name @name end |
Class Method Details
.new_from_hash(db, hash) ⇒ Object
28 29 30 31 32 |
# File 'lib/taggata/persistent/tag.rb', line 28 def self.new_from_hash(db, hash) self.new(db, hash[:name], hash[:id]) end |
.table ⇒ Object
34 35 36 |
# File 'lib/taggata/persistent/tag.rb', line 34 def self.table :taggata_tags end |
Instance Method Details
#file_tags ⇒ Object
17 18 19 |
# File 'lib/taggata/persistent/tag.rb', line 17 def FileTag.find(db, :tag_id => id) end |
#files ⇒ Object
13 14 15 |
# File 'lib/taggata/persistent/tag.rb', line 13 def files .map { |file_tag| file_tag.file } end |
#to_hash ⇒ Object
21 22 23 24 25 26 |
# File 'lib/taggata/persistent/tag.rb', line 21 def to_hash { :name => name, :id => id } end |