Class: Zazu::Resources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/zazu/resources/base.rb

Overview

Shared scaffolding for every resource module. Carries a back- reference to the client and exposes thin HTTP helpers that delegate to Client#request.

Note on naming: the helpers are ‘http_get`, `http_post`, etc. rather than `get`/`post` so they do not shadow the public methods on resource subclasses. Public resources commonly define a `get(id)` method, and a same-named private helper on the base class would let `Base#list_page` accidentally dispatch to the subclass version when a list endpoint is hit.

Pagination:

Every resource that has a list endpoint exposes `#list` which
returns a {Zazu::Page}. Callers can walk pages explicitly via
`page.next` or use `each_page_record` for capped iteration.

Constant Summary collapse

MAX_PER_PAGE =
Page::MAX_PER_PAGE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Base

Returns a new instance of Base.



26
27
28
# File 'lib/zazu/resources/base.rb', line 26

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



24
25
26
# File 'lib/zazu/resources/base.rb', line 24

def client
  @client
end