Class: Vhx::VhxObject
Constant Summary
collapse
- ASSOCIATION_WHITELIST =
['products', 'sites', 'site', 'videos', 'video', 'subscription', 'items', 'customer']
Instance Method Summary
collapse
#get_hypermedia, #get_klass
Constructor Details
#initialize(obj_hash) ⇒ VhxObject
Returns a new instance of VhxObject.
6
7
8
9
10
11
12
|
# File 'lib/vhx/utilities/vhx_object.rb', line 6
def initialize(obj_hash)
@obj_hash = obj_hash
validate_class(obj_hash)
create_readers(obj_hash)
create_associations(obj_hash)
end
|
Instance Method Details
#_embedded ⇒ Object
38
39
40
|
# File 'lib/vhx/utilities/vhx_object.rb', line 38
def _embedded
JSON.parse(@obj_hash['_embedded'].to_json)
end
|
#_links ⇒ Object
34
35
36
|
# File 'lib/vhx/utilities/vhx_object.rb', line 34
def _links
JSON.parse(@obj_hash['_links'].to_json)
end
|
#href ⇒ Object
22
23
24
|
# File 'lib/vhx/utilities/vhx_object.rb', line 22
def href
@obj_hash['_links']['self']['href']
end
|
#links ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/vhx/utilities/vhx_object.rb', line 26
def links
data = {}
@obj_hash['_links'].each do |k, v|
data[k] = v['href']
end
return OpenStruct.new(data)
end
|
#to_hash ⇒ Object
18
19
20
|
# File 'lib/vhx/utilities/vhx_object.rb', line 18
def to_hash
@obj_hash
end
|
#to_json ⇒ Object
14
15
16
|
# File 'lib/vhx/utilities/vhx_object.rb', line 14
def to_json
@obj_hash.to_json
end
|