Class: Dgrid::API::Entity
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#change_string_keys_to_symbol_keys, #set_members_from_hash, #split_hash
included
Constructor Details
#initialize(options) ⇒ Entity
Returns a new instance of Entity.
11
12
13
14
15
16
17
18
19
|
# File 'lib/dgrid/api/entity.rb', line 11
def initialize(options)
@id = nil
set_members_from_hash(options)
@description ||= ''
@workspaces = {}
end
|
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
7
8
9
|
# File 'lib/dgrid/api/entity.rb', line 7
def description
@description
end
|
#id ⇒ Object
Returns the value of attribute id.
7
8
9
|
# File 'lib/dgrid/api/entity.rb', line 7
def id
@id
end
|
#workspaces ⇒ Object
Returns the value of attribute workspaces.
85
86
87
|
# File 'lib/dgrid/api/entity.rb', line 85
def workspaces
@workspaces
end
|
Class Method Details
.pluralized ⇒ Object
58
59
60
|
# File 'lib/dgrid/api/entity.rb', line 58
def self.pluralized
'entities'
end
|
.singular ⇒ Object
29
30
31
|
# File 'lib/dgrid/api/entity.rb', line 29
def self.singular
name.split('::').last.downcase
end
|
.type ⇒ Object
21
22
23
|
# File 'lib/dgrid/api/entity.rb', line 21
def self.type
self.name.split('::').last
end
|
Instance Method Details
#add_entity(entity) ⇒ Object
62
63
64
65
66
67
68
69
|
# File 'lib/dgrid/api/entity.rb', line 62
def add_entity(entity)
workspaces.each do |workspace_id,workspace|
if entity.in_workspace?(workspace)
workspace.subordinate_entity_to_other_entity(entity, self)
end
end
end
|
#add_workspace(workspace) ⇒ Object
45
46
47
48
|
# File 'lib/dgrid/api/entity.rb', line 45
def add_workspace(workspace)
@workspaces[workspace.id] = workspace
self
end
|
#attach(filename) ⇒ Object
71
72
73
74
75
|
# File 'lib/dgrid/api/entity.rb', line 71
def attach(filename)
conn = connection
conn.attach_file_to_entity_in_workspace(self,filename,first_workspace.id)
end
|
#connection ⇒ Object
77
78
79
|
# File 'lib/dgrid/api/entity.rb', line 77
def connection
first_workspace.connection
end
|
#first_workspace ⇒ Object
81
82
83
|
# File 'lib/dgrid/api/entity.rb', line 81
def first_workspace
workspaces.values.first
end
|
#in_workspace?(workspace) ⇒ Boolean
41
42
43
|
# File 'lib/dgrid/api/entity.rb', line 41
def in_workspace?(workspace)
return @workspaces.include?(workspace.id)
end
|
#link_to(other, options = {}) ⇒ Object
36
37
38
39
|
# File 'lib/dgrid/api/entity.rb', line 36
def link_to(other, options = {})
raise UnimplementedFunctionality
self
end
|
#new_record? ⇒ Boolean
54
55
56
|
# File 'lib/dgrid/api/entity.rb', line 54
def new_record?
@id.nil?
end
|
#to_hash ⇒ Object
50
51
52
|
# File 'lib/dgrid/api/entity.rb', line 50
def to_hash
{ :description => description }
end
|
#type ⇒ Object
25
26
27
|
# File 'lib/dgrid/api/entity.rb', line 25
def type
self.class.type
end
|