Module: Generalis::Transaction::DSL
- Defined in:
- lib/generalis/transaction/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
- #credit(&block) ⇒ void
- #debit(&block) ⇒ void
- #description(&block) ⇒ Object
- #double_entry(&block) ⇒ Object
- #metadata(&block) ⇒ Object
- #occurred_at(&block) ⇒ Object
- #transaction_id(&block) ⇒ Object
Class Method Details
.extended(klass) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/generalis/transaction/dsl.rb', line 9 def self.extended(klass) super(klass) klass.include(Preparation) klass.before_validation(:prepare, if: :new_record?) end |
Instance Method Details
#credit(&block) ⇒ void
This method returns an undefined value.
41 42 43 44 45 46 47 48 |
# File 'lib/generalis/transaction/dsl.rb', line 41 def credit(&block) prepare_with do credit = Credit.new instance_exec(credit, &block) entries << credit end end |
#debit(&block) ⇒ void
This method returns an undefined value.
51 52 53 54 55 56 57 58 |
# File 'lib/generalis/transaction/dsl.rb', line 51 def debit(&block) prepare_with do debit = Debit.new instance_exec(debit, &block) entries << debit end end |
#description(&block) ⇒ Object
22 23 24 25 26 |
# File 'lib/generalis/transaction/dsl.rb', line 22 def description(&block) prepare_with do self.description = instance_exec(&block) end end |
#double_entry(&block) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/generalis/transaction/dsl.rb', line 60 def double_entry(&block) prepare_with do pair = DoubleEntry.new instance_exec(pair, &block) entries << pair.entries end end |
#metadata(&block) ⇒ Object
28 29 30 31 32 |
# File 'lib/generalis/transaction/dsl.rb', line 28 def (&block) prepare_with do self. = instance_exec(&block) end end |
#occurred_at(&block) ⇒ Object
34 35 36 37 38 |
# File 'lib/generalis/transaction/dsl.rb', line 34 def occurred_at(&block) prepare_with do self.occurred_at = instance_exec(&block) end end |
#transaction_id(&block) ⇒ Object
16 17 18 19 20 |
# File 'lib/generalis/transaction/dsl.rb', line 16 def transaction_id(&block) prepare_with do self.transaction_id = instance_exec(&block) end end |