Class: GpWebpay::Configuration
- Inherits:
-
Object
- Object
- GpWebpay::Configuration
- Defined in:
- lib/gp_webpay/configuration.rb
Defined Under Namespace
Classes: MerchantConfig
Instance Attribute Summary collapse
-
#cards_controller ⇒ Object
Returns the value of attribute cards_controller.
-
#configurations ⇒ Object
Returns the value of attribute configurations.
-
#mount_at ⇒ Object
Returns the value of attribute mount_at.
-
#orders_controller ⇒ Object
Returns the value of attribute orders_controller.
-
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
Instance Method Summary collapse
- #[](config_name) ⇒ Object
- #add_configuration(merchant_number:, default: false) {|| ... } ⇒ Object
- #default ⇒ Object
- #find_configuration_by_merchant_number(merchant_number) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #remove_configuration(merchant_number:) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 9 10 11 |
# File 'lib/gp_webpay/configuration.rb', line 5 def initialize @configurations = {} @parent_controller = 'AbstractController::Base' @mount_at = '/gp_webpay' @orders_controller = 'OrdersController' @cards_controller = 'CardsController' end |
Instance Attribute Details
#cards_controller ⇒ Object
Returns the value of attribute cards_controller.
3 4 5 |
# File 'lib/gp_webpay/configuration.rb', line 3 def cards_controller @cards_controller end |
#configurations ⇒ Object
Returns the value of attribute configurations.
3 4 5 |
# File 'lib/gp_webpay/configuration.rb', line 3 def configurations @configurations end |
#mount_at ⇒ Object
Returns the value of attribute mount_at.
3 4 5 |
# File 'lib/gp_webpay/configuration.rb', line 3 def mount_at @mount_at end |
#orders_controller ⇒ Object
Returns the value of attribute orders_controller.
3 4 5 |
# File 'lib/gp_webpay/configuration.rb', line 3 def orders_controller @orders_controller end |
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
3 4 5 |
# File 'lib/gp_webpay/configuration.rb', line 3 def parent_controller @parent_controller end |
Instance Method Details
#[](config_name) ⇒ Object
17 18 19 20 21 |
# File 'lib/gp_webpay/configuration.rb', line 17 def [](config_name) return if config_name.blank? @configurations[config_name] || find_configuration_by_merchant_number(config_name) end |
#add_configuration(merchant_number:, default: false) {|| ... } ⇒ Object
30 31 32 33 34 |
# File 'lib/gp_webpay/configuration.rb', line 30 def add_configuration(merchant_number:, default: false) @configurations[merchant_number] = MerchantConfig.new(merchant_number) yield(@configurations[merchant_number]) @configurations[:default] = @configurations[merchant_number] if default || !@configurations[:default] end |
#default ⇒ Object
13 14 15 |
# File 'lib/gp_webpay/configuration.rb', line 13 def default @configurations[:default] end |
#find_configuration_by_merchant_number(merchant_number) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/gp_webpay/configuration.rb', line 23 def find_configuration_by_merchant_number(merchant_number) config = @configurations.find { |_key, value| value.merchant_number.to_s == merchant_number.to_s } return nil if config.blank? config[-1] end |
#remove_configuration(merchant_number:) ⇒ Object
36 37 38 39 |
# File 'lib/gp_webpay/configuration.rb', line 36 def remove_configuration(merchant_number:) @configurations.delete(merchant_number) @configurations[:default] = @configurations[@configurations.keys[0]] end |