Class: Enginn::ProjectsIndex

Inherits:
ResourceIndex show all
Defined in:
lib/enginn/projects_index.rb

Instance Attribute Summary collapse

Attributes inherited from ResourceIndex

#errors, #filters, #pagination, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ResourceIndex

#each, #fetch, #inspect, #page, path, #per, #where

Constructor Details

#initialize(client) ⇒ ProjectsIndex

Returns a new instance of ProjectsIndex.

Parameters:

  • client (Enginn::Client)

    The client to use with this project and resources



13
14
15
16
# File 'lib/enginn/projects_index.rb', line 13

def initialize(client)
  @client = client
  super(self)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/enginn/projects_index.rb', line 10

def client
  @client
end

Class Method Details

.resourceObject



6
7
8
# File 'lib/enginn/projects_index.rb', line 6

def self.resource
  Project
end

Instance Method Details

#fetch!Object



19
20
21
22
23
24
25
26
# File 'lib/enginn/projects_index.rb', line 19

def fetch!
  response = request
  @pagination = response[:pagination]
  @collection = response[:result].map do |attributes|
    self.class.resource.new(@client, attributes)
  end
  self
end

#routeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/enginn/projects_index.rb', line 29

def route
  'projects'
end