Class: HelloSign::Resource::ResourceArray

Inherits:
Array
  • Object
show all
Defined in:
lib/hello_sign/resource/resource_array.rb

Overview

Stores an array of HelloSign BaseResource with paging information

Author:

  • hellosign

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash, key, resource_class) ⇒ HelloSign::Resource::ResourceArray

Creates a new ResourceArray from a hash

Parameters:

  • hash (Hash)

    Data of the array.

  • key (String)

    Key of the hash, point to where resource array data is.

  • resource_class (Class)

    a ResourceClass object inherited from BaseResource. Uses the created array item from hash.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/hello_sign/resource/resource_array.rb', line 39

def initialize(hash, key, resource_class)
  @headers = hash[:headers]
  @data = hash[:body]
  @list_info = hash[:body]['list_info']
  @page = @list_info['page']
  @num_pages = @list_info['num_pages']
  @num_results = @list_info['num_results']
  @page_size = @list_info['page_size']
  @warnings = hash[:body]['warnings'] ? hash[:body]['warnings'] : nil
  self << resource_class.new(hash[:body], nil)

  hash[key] && hash[key].each do |resource|
    self << resource_class.new(resource, nil)
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def data
  @data
end

#headersObject (readonly)

Returns the value of attribute headers.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def headers
  @headers
end

#list_infoObject (readonly)

Returns the value of attribute list_info.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def list_info
  @list_info
end

#num_pagesObject (readonly)

Returns the value of attribute num_pages.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def num_pages
  @num_pages
end

#num_resultsObject (readonly)

Returns the value of attribute num_results.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def num_results
  @num_results
end

#pageObject (readonly)

Returns the value of attribute page.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def page
  @page
end

#page_sizeObject (readonly)

Returns the value of attribute page_size.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def page_size
  @page_size
end

#warningsObject (readonly)

Returns the value of attribute warnings.



30
31
32
# File 'lib/hello_sign/resource/resource_array.rb', line 30

def warnings
  @warnings
end