Class: CostAgent::Base

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

Overview

This provides shared functionality for all of the wrapped FA data types

Direct Known Subclasses

Invoice, InvoiceItem, Project, Task, Timeslip, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
16
# File 'lib/costagent.rb', line 13

def initialize(data = {})
  @data = {}
  data.keys.each { |key| @data[key.to_s] = data[key] }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/costagent.rb', line 18

def method_missing(name, *args)
  key = name.to_s
  if key[key.length - 1] == "="
    @data[key[0...key.length - 1]] = args.first
  end
  @data[key]
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



11
12
13
# File 'lib/costagent.rb', line 11

def data
  @data
end

Instance Method Details

#idObject



26
27
28
# File 'lib/costagent.rb', line 26

def id
  @data["id"]
end