Class: Remitmd::Model
- Inherits:
-
Object
- Object
- Remitmd::Model
- Defined in:
- lib/remitmd/models.rb
Overview
Immutable model base. Builds from a hash with string or symbol keys.
Direct Known Subclasses
Balance, Bounty, BountySubmission, Budget, ContractAddresses, Deposit, Escrow, LinkResponse, Reputation, SpendingSummary, Stream, Tab, TabDebit, Transaction, TransactionList, WalletSettings, Webhook
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Model
constructor
A new instance of Model.
- #inspect ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Model
Returns a new instance of Model.
78 79 80 81 82 83 |
# File 'lib/remitmd/models.rb', line 78 def initialize(attrs) attrs.each do |k, v| instance_variable_set("@#{k}", v) self.class.attr_reader(k.to_sym) unless respond_to?(k.to_sym) end end |
Instance Method Details
#inspect ⇒ Object
91 92 93 |
# File 'lib/remitmd/models.rb', line 91 def inspect "#<#{self.class.name} #{to_h}>" end |
#to_h ⇒ Object
85 86 87 88 89 |
# File 'lib/remitmd/models.rb', line 85 def to_h instance_variables.each_with_object({}) do |var, h| h[var.to_s.delete("@").to_sym] = instance_variable_get(var) end end |