Class: Setting

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/setting.rb

Instance Method Summary collapse

Instance Method Details

#cheque_message(order) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/setting.rb', line 6

def cheque_message(order)
  return "" unless order.is_a? Order
  if payment_method_available?(:cheque)
    message = payment_methods[:cheque][:message]
    message = message.gsub('#{ORDER_ID}', order.reference.to_s)
    message = message.gsub('#{USER_NAME}', order.user.fullname)
  else
    message = ""
  end
  message
end

#colissimo_method_available?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/setting.rb', line 42

def colissimo_method_available?
  colissimo_methods[:active] == '1' if colissimo_methods
end

#payment_method_available?(k) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/models/setting.rb', line 18

def payment_method_available?(k)
  payment_methods[k.to_sym] && payment_methods[k.to_sym][:active] == '1'
end

#payment_method_availablesObject



22
23
24
# File 'app/models/setting.rb', line 22

def payment_method_availables
  payment_methods.keys.reject { |k| not payment_method_available?(k) }
end

#payment_method_env(k) ⇒ Object



30
31
32
# File 'app/models/setting.rb', line 30

def payment_method_env(k)
  payment_method_for_test?(k) ? :development : :production
end

#payment_method_for_test?(k) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/setting.rb', line 26

def payment_method_for_test?(k)
  payment_methods[k.to_sym] && payment_methods[k.to_sym][:test] == '1'
end

#payment_method_settings(k) ⇒ Object



34
35
36
# File 'app/models/setting.rb', line 34

def payment_method_settings(k)
  payment_methods[k.to_sym] if payment_method_available?(k)
end

#payment_method_settings_with_env(k) ⇒ Object



38
39
40
# File 'app/models/setting.rb', line 38

def payment_method_settings_with_env(k)
  payment_method_settings(k)[payment_method_env(k)] if payment_method_available?(k)
end