Class: Makeleaps::Response::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/makeleaps/response/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject

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_arrayObject

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