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!
#create, #create!
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
38
39
40
41
42
|
# File 'lib/lhs/collection.rb', line 38
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
22
23
24
25
26
|
# File 'lib/lhs/collection.rb', line 22
def _collection
raw = _data._raw if _data._raw.is_a?(Array)
raw ||= _data._raw[items_key]
Collection.new(raw, _data, _record)
end
|
14
15
16
|
# File 'lib/lhs/collection.rb', line 14
def
_record.(_data)
end
|
#collection? ⇒ Boolean
28
29
30
|
# File 'lib/lhs/collection.rb', line 28
def collection?
true
end
|
#href ⇒ Object
18
19
20
|
# File 'lib/lhs/collection.rb', line 18
def href
_data._raw[:href]
end
|
#item? ⇒ Boolean
32
33
34
|
# File 'lib/lhs/collection.rb', line 32
def item?
false
end
|