Class: Makeleaps::Response::Resource
- Inherits:
-
Object
- Object
- Makeleaps::Response::Resource
- Defined in:
- lib/makeleaps/response/resource.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
-
#content_as_array ⇒ Object
ensure data are encupslated in an array (for interface consistency).
- #each_resource(&block) ⇒ Object
- #find_resource(*args, &block) ⇒ Object
-
#initialize(content) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(content) ⇒ Resource
Returns a new instance of Resource.
6 7 8 |
# File 'lib/makeleaps/response/resource.rb', line 6 def initialize(content) @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/makeleaps/response/resource.rb', line 4 def content @content end |
Instance Method Details
#content_as_array ⇒ Object
ensure data are encupslated in an array (for interface consistency)
11 12 13 |
# File 'lib/makeleaps/response/resource.rb', line 11 def content_as_array [content].flatten end |
#each_resource(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/makeleaps/response/resource.rb', line 15 def each_resource(&block) if block_given? content_as_array.each do |resource| block.call(resource) end else content_as_array.to_enum end end |
#find_resource(*args, &block) ⇒ Object
25 26 27 |
# File 'lib/makeleaps/response/resource.rb', line 25 def find_resource(*args, &block) content_as_array.find(*args, &block) end |