Class: Roulette::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/roulette.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stores, *args) ⇒ Transaction

Returns a new instance of Transaction.



29
30
31
32
33
# File 'lib/roulette.rb', line 29

def initialize(stores, *args)
  self.stores = stores
  self.args = *args
  extract_key
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



26
27
28
# File 'lib/roulette.rb', line 26

def args
  @args
end

#keyObject

Returns the value of attribute key.



26
27
28
# File 'lib/roulette.rb', line 26

def key
  @key
end

#storesObject

Returns the value of attribute stores.



26
27
28
# File 'lib/roulette.rb', line 26

def stores
  @stores
end

Instance Method Details

#extract_keyObject



35
36
37
38
39
40
# File 'lib/roulette.rb', line 35

def extract_key
  # there is a 'bug' with something in the rails library that when loaded will
  # produce Roulette::Transaction.new([], "key") # => "k" instead of "key"
  # this is a fix for that, but i don't know what in rails env causes this discrepency
  self.key = args.is_a?(Array) ? args.first.to_s : args.to_s
end

#fire(method) ⇒ Object



42
43
44
# File 'lib/roulette.rb', line 42

def fire(method)
  select_store.send method.to_sym, *args
end