Class: ModernTreasury::LedgerEventHandlerConditions

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/ledger_event_handler_conditions.rb

Overview

LedgerEventHandlerConditions Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(field:, operator:, value:) ⇒ LedgerEventHandlerConditions

Returns a new instance of LedgerEventHandlerConditions.



44
45
46
47
48
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 44

def initialize(field:, operator:, value:)
  @field = field
  @operator = operator
  @value = value
end

Instance Attribute Details

#fieldString

The field you’re fetching from the ‘ledgerable_event`.

Returns:

  • (String)


14
15
16
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 14

def field
  @field
end

#operatorString

What the operator between the ‘field` and `value` is. Currently only supports `equals`.

Returns:

  • (String)


19
20
21
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 19

def operator
  @operator
end

#valueString

What raw string you are comparing the ‘field` against.

Returns:

  • (String)


23
24
25
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 23

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 51

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  field = hash.key?('field') ? hash['field'] : nil
  operator = hash.key?('operator') ? hash['operator'] : nil
  value = hash.key?('value') ? hash['value'] : nil

  # Create object from extracted values.
  LedgerEventHandlerConditions.new(field: field,
                                   operator: operator,
                                   value: value)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['field'] = 'field'
  @_hash['operator'] = 'operator'
  @_hash['value'] = 'value'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 35

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



72
73
74
75
76
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 72

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} field: #{@field.inspect}, operator: #{@operator.inspect}, value:"\
  " #{@value.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



66
67
68
69
# File 'lib/modern_treasury/models/ledger_event_handler_conditions.rb', line 66

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} field: #{@field}, operator: #{@operator}, value: #{@value}>"
end