Class: AspireBudget::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/aspire_budget/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sessionGoogleDrive::Session

Authenticated GoogleDrive session

Returns:

  • (GoogleDrive::Session)


28
29
30
# File 'lib/aspire_budget/configuration.rb', line 28

def session
  @session
end

#spreadsheet_keyString

Google spreadsheet key (as it is in the url)

Returns:

  • (String)


32
33
34
# File 'lib/aspire_budget/configuration.rb', line 32

def spreadsheet_key
  @spreadsheet_key
end

Instance Method Details

#agent(session = nil, spreadsheet_key = nil) ⇒ GoogleDrive::Spreadsheet

Build an agent using given session and spreadsheet_key (falling back to the configured ones).

Parameters:

  • session (GoogleDrive::Session) (defaults to: nil)

    will fallback to configured one if not defined

  • spreadsheet_key (String) (defaults to: nil)

    will fallback to configured one if not defined

Returns:

  • (GoogleDrive::Spreadsheet)

    an spreadsheet agent



41
42
43
44
45
46
47
48
# File 'lib/aspire_budget/configuration.rb', line 41

def agent(session = nil, spreadsheet_key = nil)
  @agents ||= Hash.new do |h, k|
    h[k] = k.first.spreadsheet_by_key(k.last)
  end
  @agents[
    [session || self.session, spreadsheet_key || self.spreadsheet_key]
  ]
end