Class: LiquidPlanner::Base
- Inherits:
-
Object
- Object
- LiquidPlanner::Base
- 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
- #account ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #workspaces(scope = :all) ⇒ Object
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(={}) .assert_valid_keys(:email, :password, :api_base_url) .assert_required_keys(:email, :password) @email = [:email] @password = [:password] @api_base_url = [:api_base_url] || LiquidPlanner::API_BASE_URL configure_base_resource end |
Instance Method Details
#account ⇒ Object
20 21 22 |
# File 'lib/liquidplanner/base.rb', line 20 def account 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 |