Class: Vhx::VhxListObject
- Inherits:
-
Array
- Object
- Array
- Vhx::VhxListObject
- Defined in:
- lib/vhx/utilities/vhx_list_object.rb
Instance Method Summary collapse
-
#initialize(obj, list_type) ⇒ VhxListObject
constructor
A new instance of VhxListObject.
- #next ⇒ Object
- #previous ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(obj, list_type) ⇒ VhxListObject
Returns a new instance of VhxListObject.
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/vhx/utilities/vhx_list_object.rb', line 4 def initialize(obj, list_type) @obj = obj if @obj.is_a?(Array) ar = @obj.map{|association_hash| Object.const_get("Vhx::#{vhx_object_type(list_type)}").new(association_hash)} elsif @obj.is_a?(Hash) @previous, @next = @obj['_links']['prev']['href'], @obj['_links']['next']['href'] @total = @obj['total'] ar = @obj['_embedded'][list_type].map{|association_hash| Object.const_get("Vhx::#{vhx_object_type(list_type)}").new(association_hash)} end super(ar) end |
Instance Method Details
#next ⇒ Object
22 23 24 |
# File 'lib/vhx/utilities/vhx_list_object.rb', line 22 def next @next # TODO end |
#previous ⇒ Object
18 19 20 |
# File 'lib/vhx/utilities/vhx_list_object.rb', line 18 def previous @previous # TODO end |
#total ⇒ Object
26 27 28 |
# File 'lib/vhx/utilities/vhx_list_object.rb', line 26 def total @total end |