Class: HornOfPlenty::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/horn_of_plenty/repository.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil) ⇒ Repository



8
9
10
# File 'lib/horn_of_plenty/repository.rb', line 8

def initialize(client: nil)
  self.client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/horn_of_plenty/repository.rb', line 6

def client
  @client
end

Class Method Details

.fetch(**attrs) ⇒ Object



23
24
25
26
27
# File 'lib/horn_of_plenty/repository.rb', line 23

def self.fetch(**attrs)
  client = attrs.delete(:client)

  new(client: client).fetch(attrs)
end

Instance Method Details

#fetch(**attrs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/horn_of_plenty/repository.rb', line 12

def fetch(**attrs)
  pagination = attrs[:pagination] || {}
  request    = fetch_class(attrs).new(**attrs)

  Paginator.new(client:         client,
                request:        request,
                items_per_page: pagination[:page_size],
                current_page:   pagination[:page_number],
                autopage:       pagination.fetch(:autopage, true))
end