Class: Royal::Transaction::Operation

Inherits:
Struct
  • Object
show all
Defined in:
lib/royal/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#amountObject

Returns the value of attribute amount

Returns:

  • (Object)

    the current value of amount



5
6
7
# File 'lib/royal/transaction.rb', line 5

def amount
  @amount
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



5
6
7
# File 'lib/royal/transaction.rb', line 5

def owner
  @owner
end

#pointableObject

Returns the value of attribute pointable

Returns:

  • (Object)

    the current value of pointable



5
6
7
# File 'lib/royal/transaction.rb', line 5

def pointable
  @pointable
end

#reasonObject

Returns the value of attribute reason

Returns:

  • (Object)

    the current value of reason



5
6
7
# File 'lib/royal/transaction.rb', line 5

def reason
  @reason
end

Instance Method Details

#performvoid

This method returns an undefined value.



7
8
9
# File 'lib/royal/transaction.rb', line 7

def perform
  owner.add_points(amount, reason: reason, pointable: pointable)
end

#sorting_keyArray

Used to ensure a deterministic order of operations in a transaction to avoid deadlocks.

Returns:

  • (Array)


14
15
16
# File 'lib/royal/transaction.rb', line 14

def sorting_key
  [owner.class.polymorphic_name, owner.id, -amount]
end