Class: LiquidPlanner::Base

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

Overview

sets up the URL and credentials for an API “session”, then provides convenience accessors for the account and workspaces

N.B. since ActiveResource uses class variables to configure endpoint and auth, you can only have one such “session” active at a time

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
# File 'lib/liquidplanner/base.rb', line 11

def initialize(options={})
  options.assert_valid_keys(:email, :password, :api_base_url)
  options.assert_required_keys(:email, :password)
  @email        = options[:email]
  @password     = options[:password]
  @api_base_url = options[:api_base_url] || LiquidPlanner::API_BASE_URL
  configure_base_resource
end

Instance Method Details

#accountObject



20
21
22
# File 'lib/liquidplanner/base.rb', line 20

def 
  LiquidPlanner::Resources::Account.find(:one, :from => "/api/account")
end

#workspaces(scope = :all) ⇒ Object



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

def workspaces( scope=:all )
  LiquidPlanner::Resources::Workspace.find(scope)
end