Class: Checkoff::Workspaces

Inherits:
Object
  • Object
show all
Defined in:
lib/checkoff/workspaces.rb

Overview

Query different workspaces of Asana projects

Constant Summary collapse

MINUTE =
60
HOUR =
MINUTE * 60
DAY =
24 * HOUR
REALLY_LONG_CACHE_TIME =
HOUR * 1
LONG_CACHE_TIME =
MINUTE * 15
SHORT_CACHE_TIME =
MINUTE

Instance Method Summary collapse

Constructor Details

#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), client: Checkoff::Clients.new(config: config).client) ⇒ Workspaces

Returns a new instance of Workspaces.



20
21
22
23
24
# File 'lib/checkoff/workspaces.rb', line 20

def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
               client: Checkoff::Clients.new(config: config).client)
  @config = config
  @client = client
end

Instance Method Details

#workspace(workspace_name) ⇒ Object

Pulls an Asana workspace object



27
28
29
30
31
# File 'lib/checkoff/workspaces.rb', line 27

def workspace(workspace_name)
  client.workspaces.find_all.find do |workspace|
    workspace.name == workspace_name
  end
end

#workspace_or_raise(workspace_name) ⇒ Object



33
34
35
36
37
38
# File 'lib/checkoff/workspaces.rb', line 33

def workspace_or_raise(workspace_name)
  workspace = workspace(workspace_name)
  raise "Could not find workspace #{workspace_name}" if workspace.nil?

  workspace
end