Class: Setting
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Setting
- Defined in:
- app/models/setting.rb
Instance Method Summary collapse
- #cheque_message(order) ⇒ Object
- #colissimo_method_available? ⇒ Boolean
- #payment_method_available?(k) ⇒ Boolean
- #payment_method_availables ⇒ Object
- #payment_method_env(k) ⇒ Object
- #payment_method_for_test?(k) ⇒ Boolean
- #payment_method_settings(k) ⇒ Object
- #payment_method_settings_with_env(k) ⇒ Object
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 (order) return "" unless order.is_a? Order if payment_method_available?(:cheque) = payment_methods[:cheque][:message] = .gsub('#{ORDER_ID}', order.reference.to_s) = .gsub('#{USER_NAME}', order.user.fullname) else = "" end end |
#colissimo_method_available? ⇒ 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
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_availables ⇒ Object
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
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 |