Class: LHS::Collection
Overview
A collection is a special type of data that contains multiple items
Defined Under Namespace
Modules: InternalCollection
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
33
34
35
36
37
|
# File 'lib/lhs/collection.rb', line 33
def method_missing(name, *args, &block)
value = _collection.send(name, *args, &block)
return enclose_in_data(value) if value.is_a? Hash
value
end
|
Instance Method Details
#_collection ⇒ Object
21
22
23
24
25
|
# File 'lib/lhs/collection.rb', line 21
def _collection
raw = _data._raw if _data._raw.is_a?(Array)
raw ||= _data._raw[items_key]
Collection.new(raw, _data, _record)
end
|
13
14
15
|
# File 'lib/lhs/collection.rb', line 13
def
_record.(_data)
end
|
#collection? ⇒ Boolean
27
28
29
|
# File 'lib/lhs/collection.rb', line 27
def collection?
true
end
|
#href ⇒ Object
17
18
19
|
# File 'lib/lhs/collection.rb', line 17
def href
_data._raw[:href]
end
|