Class: TFSGraph::PersistableEntity
Constant Summary
collapse
- NotPersisted =
Class.new(RuntimeError)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Extensions
#base_class_name
Methods inherited from Entity
inherited, #schema
Constructor Details
Returns a new instance of PersistableEntity.
17
18
19
20
|
# File 'lib/tfs_graph/persistable_entity.rb', line 17
def initialize(repo, args)
@repo = repo
super args
end
|
Instance Attribute Details
#db_object ⇒ Object
Returns the value of attribute db_object.
11
12
13
|
# File 'lib/tfs_graph/persistable_entity.rb', line 11
def db_object
@db_object
end
|
#id ⇒ Object
Returns the value of attribute id.
11
12
13
|
# File 'lib/tfs_graph/persistable_entity.rb', line 11
def id
@id
end
|
Class Method Details
.repository ⇒ Object
13
14
15
|
# File 'lib/tfs_graph/persistable_entity.rb', line 13
def self.repository
TFSGraph::RepositoryRegistry.instance.send "#{base_class_name.downcase}_repository"
end
|
Instance Method Details
#delete! ⇒ Object
30
31
32
33
34
35
|
# File 'lib/tfs_graph/persistable_entity.rb', line 30
def delete!
@repo.delete(self)
@db_object = nil
@id = nil
end
|
#persist(id, db_object) ⇒ Object
37
38
39
40
41
42
|
# File 'lib/tfs_graph/persistable_entity.rb', line 37
def persist(id, db_object)
@id ||= id
@db_object = db_object
self
end
|
#persisted? ⇒ Boolean
22
23
24
|
# File 'lib/tfs_graph/persistable_entity.rb', line 22
def persisted?
!db_object.nil?
end
|
#save! ⇒ Object
26
27
28
|
# File 'lib/tfs_graph/persistable_entity.rb', line 26
def save!
@repo.save(self)
end
|
#to_hash ⇒ Object
53
54
55
56
57
58
|
# File 'lib/tfs_graph/persistable_entity.rb', line 53
def to_hash
hash = super
hash[:id] = id
hash
end
|