Class: Transaction
- Inherits:
-
Object
- Object
- Transaction
- Defined in:
- lib/shilling/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(from, to, amount, id = SecureRandom.uuid) ⇒ Transaction
constructor
A new instance of Transaction.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(from, to, amount, id = SecureRandom.uuid) ⇒ Transaction
Returns a new instance of Transaction.
7 8 9 10 11 12 |
# File 'lib/shilling/transaction.rb', line 7 def initialize( from, to, amount, id=SecureRandom.uuid ) @from = from @to = to @amount = amount @id = id end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
5 6 7 |
# File 'lib/shilling/transaction.rb', line 5 def amount @amount end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/shilling/transaction.rb', line 5 def from @from end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/shilling/transaction.rb', line 5 def id @id end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
5 6 7 |
# File 'lib/shilling/transaction.rb', line 5 def to @to end |
Class Method Details
.from_h(hash) ⇒ Object
14 15 16 |
# File 'lib/shilling/transaction.rb', line 14 def self.from_h( hash ) self.new *hash.values_at( 'from', 'to', 'amount', 'id' ) end |
Instance Method Details
#to_h ⇒ Object
18 19 20 |
# File 'lib/shilling/transaction.rb', line 18 def to_h { from: @from, to: @to, amount: @amount, id: @id } end |
#valid? ⇒ Boolean
23 24 25 26 |
# File 'lib/shilling/transaction.rb', line 23 def valid? ## check signature in the future; for now always true true end |