class AspireBudget::Worksheets::WorksheetBase

@abstract Subclass and reimplement ws_title to implement a custom

worksheet

Public Class Methods

instance() click to toggle source

@return an instance of the current object

# File lib/aspire_budget/worksheets/worksheet_base.rb, line 12
def instance
  Thread.current[to_s] ||= new
end
new(session: nil, spreadsheet_key: nil) click to toggle source

@see AspireBudget::Configuration#agent @return a new instance of the calling class configured with an agent @param session [GoogleDrive::Session] @param spreadsheet_key [String] spreadsheet key as per its url

# File lib/aspire_budget/worksheets/worksheet_base.rb, line 35
def initialize(session: nil, spreadsheet_key: nil)
  @session = session
  @spreadsheet_key = spreadsheet_key
  @agent = AspireBudget.configuration.agent(@session, @spreadsheet_key)
end

Private Class Methods

method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/aspire_budget/worksheets/worksheet_base.rb, line 18
def method_missing(method_name, *args, &block)
  if instance.respond_to?(method_name)
    instance.public_send(method_name, *args, &block)
  else
    super
  end
end
respond_to_missing?(method_name, _include_private) click to toggle source
Calls superclass method
# File lib/aspire_budget/worksheets/worksheet_base.rb, line 26
def respond_to_missing?(method_name, _include_private)
  instance.respond_to?(method_name) || super
end

Public Instance Methods

dirty?() click to toggle source

@return [Boolean] Whether the worksheet has unsaved changes

# File lib/aspire_budget/worksheets/worksheet_base.rb, line 42
def dirty?
  ws.dirty?
end

Private Instance Methods

worksheets() click to toggle source
# File lib/aspire_budget/worksheets/worksheet_base.rb, line 52
def worksheets
  @worksheets ||=
    @agent.worksheets.reduce({}) { |h, sheet| h.merge(sheet.title => sheet) }
end
ws() click to toggle source
# File lib/aspire_budget/worksheets/worksheet_base.rb, line 48
def ws
  worksheets[self.class::WS_TITLE]
end