class Vhx::VhxListObject
Public Class Methods
new(obj, list_type)
click to toggle source
Calls superclass method
# 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
Public Instance Methods
next()
click to toggle source
# File lib/vhx/utilities/vhx_list_object.rb, line 22 def next @next # TODO end
previous()
click to toggle source
# File lib/vhx/utilities/vhx_list_object.rb, line 18 def previous @previous # TODO end
total()
click to toggle source
# File lib/vhx/utilities/vhx_list_object.rb, line 26 def total @total end
Protected Instance Methods
vhx_object_type(list_type)
click to toggle source
# File lib/vhx/utilities/vhx_list_object.rb, line 32 def vhx_object_type(list_type) case list_type when 'items' 'Collection::Item' when 'files' 'Video::File' else list_type.gsub(/s\z/, '').capitalize end end