Class: LHS::Collection
Overview
A collection is a special type of data that contains multiple items
Defined Under Namespace
Classes: Collection
Instance Attribute Summary
Attributes inherited from Proxy
#_data, #_loaded
Instance Method Summary
collapse
Methods inherited from Proxy
#initialize, #load!, #reload!
Constructor Details
This class inherits a constructor from LHS::Proxy
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/lhs/collection.rb', line 35
def method_missing(name, *args, &block)
value = _collection.send(name, *args, &block)
if value.is_a? Hash
data = LHS::Data.new(value, _data)
item = LHS::Item.new(data)
LHS::Data.new(item, _data)
else
value
end
end
|
Instance Method Details
#_collection ⇒ Object
23
24
25
26
27
|
# File 'lib/lhs/collection.rb', line 23
def _collection
raw = _data._raw if _data._raw.is_a?(Array)
raw ||= _data._raw['items']
Collection.new(raw, _data, _data._service)
end
|
#_raw ⇒ Object
29
30
31
|
# File 'lib/lhs/collection.rb', line 29
def _raw
_data._raw
end
|
#href ⇒ Object
19
20
21
|
# File 'lib/lhs/collection.rb', line 19
def href
_data._raw['href']
end
|
#limit ⇒ Object
11
12
13
|
# File 'lib/lhs/collection.rb', line 11
def limit
_data._raw['limit']
end
|
#offset ⇒ Object
15
16
17
|
# File 'lib/lhs/collection.rb', line 15
def offset
_data._raw['offset']
end
|
#total ⇒ Object
7
8
9
|
# File 'lib/lhs/collection.rb', line 7
def total
_data._raw['total']
end
|