Class: Flow::Models::Transaction

Inherits:
Model
  • Object
show all
Defined in:
lib/flow/models/transaction.rb

Direct Known Subclasses

Credit

Instance Attribute Summary

Attributes inherited from Model

#connection, #model_hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

__load_path, #initialize, load, load_model, #method_missing, #reload, #reload!

Constructor Details

This class inherits a constructor from Flow::Models::Model

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Flow::Models::Model

Class Method Details

.__model_nameObject

Override inherited behavior. This causes subclasses of transactions to continue to be treated as transactions at the API level.



17
18
19
# File 'lib/flow/models/transaction.rb', line 17

def self.__model_name
  'transaction'
end

.build(connection, model_hash) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/flow/models/transaction.rb', line 5

def self.build(connection, model_hash)
  case model_hash['type'].to_sym
  when :credit
    return Credit.new(connection, model_hash)
  else
    raise Flow::Errors::BuildError.new("Invalid Transaction type: #{model_hash['type']}.")
  end
end

Instance Method Details

#credit?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/flow/models/transaction.rb', line 21

def credit?
  self.type == 'credit'
end