Class: Unleashed::BaseModel

Inherits:
Object
  • Object
show all
Defined in:
lib/unleashed/models/base_model.rb

Overview

Base model for all the other models to inherit from

Direct Known Subclasses

Company, Currency, Customer, Invoice, PaymentTerm

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, attributes = {}) ⇒ BaseModel

Returns a new instance of BaseModel.



6
7
8
9
# File 'lib/unleashed/models/base_model.rb', line 6

def initialize(client, attributes = {})
  @client = client
  @attributes = stringify_keys(attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/unleashed/models/base_model.rb', line 11

def method_missing(name, *args, &block)
  if @attributes.key?(name.to_s)
    @attributes[name.to_s]
  else
    super
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/unleashed/models/base_model.rb', line 4

def attributes
  @attributes
end