Class: FulfilApi::Configuration

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

Overview

Configuration model for the Fulfil gem.

This model holds configuration settings and provides thread-safe access

to these settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Initializes the configuration with optional settings.

Parameters:

  • options (Hash, nil) (defaults to: {})

    An optional list of configuration options. Each key in the hash should correspond to a configuration attribute.



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fulfil_api/configuration.rb', line 15

def initialize(options = {})
  @mutex = Mutex.new

  # Assigns the optional configuration options
  options.each_pair do |key, value|
    send(:"#{key}=", value) if respond_to?(:"#{key}=")
  end

  # Sets the default options if not provided
  set_default_options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ void

This method returns an undefined value.

Provides thread-safe access to missing methods, allowing dynamic handling of configuration options.

Parameters:

  • method (Symbol)

    The method name.

  • args (Array)

    The arguments passed to the method.

  • block (Proc)

    An optional block passed to the method.



33
34
35
# File 'lib/fulfil_api/configuration.rb', line 33

def method_missing(method, *args, &block)
  @mutex.synchronize { super }
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def access_token
  @access_token
end

#api_versionObject

Returns the value of attribute api_version.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def api_version
  @api_version
end

#merchant_idObject

Returns the value of attribute merchant_id.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def merchant_id
  @merchant_id
end

Instance Method Details

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Ensures that the object responds correctly to methods handled by method_missing.

Parameters:

  • method (Symbol)

    The method name.

  • include_private (Boolean) (defaults to: false)

    Whether to include private methods.

Returns:

  • (Boolean)

    Whether the object responds to the method.



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

def respond_to_missing?(method, include_private = false)
  @mutex.synchronize { super }
end