Class: Nfe::ListResponse

Inherits:
Data
  • Object
show all
Includes:
Enumerable, Enumerable[untyped]
Defined in:
lib/nfe/pagination.rb,
sig/nfe/pagination.rbs

Overview

A list of hydrated DTOs (+data+) plus its pagination metadata (+page+). data is iterated identically regardless of pagination shape.

Includes Enumerable (delegating each to data), so a list response is usable directly anywhere an Enumerable is expected — map, select, each_with_index, ... — without first reaching into data.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data: [], page: nil) ⇒ ListResponse

Returns a new instance of ListResponse.

Parameters:

  • data: (Object) (defaults to: [])
  • page: (Object) (defaults to: nil)


39
40
41
# File 'lib/nfe/pagination.rb', line 39

def initialize(data: [], page: nil)
  super
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.

Returns:

  • (Object)


21
22
23
# File 'sig/nfe/pagination.rbs', line 21

def data
  @data
end

#pageObject (readonly)

Returns the value of attribute page.

Returns:

  • (Object)


22
23
24
# File 'sig/nfe/pagination.rbs', line 22

def page
  @page
end

Class Method Details

.newinstance

Parameters:

  • data: (Object)
  • page: (Object)

Returns:

  • (instance)


24
# File 'sig/nfe/pagination.rbs', line 24

def self.new: (?data: untyped, ?page: untyped) -> instance

Instance Method Details

#eachvoid #eachEnumerator[untyped, void]

Iterate the hydrated DTOs in data.

Overloads:

  • #eachvoid

    This method returns an undefined value.

  • #eachEnumerator[untyped, void]

    Returns:

    • (Enumerator[untyped, void])

Yields:

Yield Parameters:

  • item

    each hydrated DTO.

  • arg0 (Object)

Yield Returns:

  • (void)

Returns:

  • (Enumerator)

    when called without a block.



47
48
49
50
51
# File 'lib/nfe/pagination.rb', line 47

def each(&)
  return enum_for(:each) unless block_given?

  data.each(&)
end