Class: ActiveInteractor::Configuration

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

Overview

The Configuration object for the ActiveInteractor gem

Author:

Since:

  • 0.0.1

Version:

  • 0.2

Constant Summary collapse

DEFAULTS =

The default configuration options for ActiveInteractor::Configuration

Returns:

  • (Hash{Symbol => *})

Since:

  • 0.0.1

{
  logger: Logger.new(STDOUT),
  dir_name: 'interactors'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ActiveInteractor::Configuration

Parameters:

  • options (Hash{Symbol => *}) (defaults to: {})

    the options to initialize the configuration with.

Options Hash (options):

  • :logger (Logger)

    the logger ActiveInteractor should use for logging

  • :dir_name (String)

    he directory name interactors are generated in

Since:

  • 0.0.1



31
32
33
34
35
36
# File 'lib/active_interactor/configuration.rb', line 31

def initialize(options = {})
  options = DEFAULTS.merge(options.dup || {}).slice(*DEFAULTS.keys)
  options.each_key do |attribute|
    instance_variable_set("@#{attribute}", options[attribute])
  end
end

Instance Attribute Details

#dir_nameString

Returns The directory name interactors are generated in.

Returns:

  • (String)

    The directory name interactors are generated in

Since:

  • 0.0.1



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_interactor/configuration.rb', line 14

class Configuration
  # The default configuration options for {Configuration}
  # @return [Hash{Symbol => *}]
  DEFAULTS = {
    logger: Logger.new(STDOUT),
    dir_name: 'interactors'
  }.freeze

  attr_accessor :logger, :dir_name

  # A new instance of {Configuration}
  # @param options [Hash{Symbol => *}] the options to initialize the
  #  configuration with.
  # @option options [Logger] :logger the logger ActiveInteractor should
  #  use for logging
  # @option options [String] :dir_name he directory name interactors are generated in
  # @return [ActiveInteractor::Configuration] a new instance of {Configuration}
  def initialize(options = {})
    options = DEFAULTS.merge(options.dup || {}).slice(*DEFAULTS.keys)
    options.each_key do |attribute|
      instance_variable_set("@#{attribute}", options[attribute])
    end
  end
end

#loggerLogger

Returns an instance of Logger.

Returns:

  • (Logger)

    an instance of Logger

Since:

  • 0.0.1



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_interactor/configuration.rb', line 14

class Configuration
  # The default configuration options for {Configuration}
  # @return [Hash{Symbol => *}]
  DEFAULTS = {
    logger: Logger.new(STDOUT),
    dir_name: 'interactors'
  }.freeze

  attr_accessor :logger, :dir_name

  # A new instance of {Configuration}
  # @param options [Hash{Symbol => *}] the options to initialize the
  #  configuration with.
  # @option options [Logger] :logger the logger ActiveInteractor should
  #  use for logging
  # @option options [String] :dir_name he directory name interactors are generated in
  # @return [ActiveInteractor::Configuration] a new instance of {Configuration}
  def initialize(options = {})
    options = DEFAULTS.merge(options.dup || {}).slice(*DEFAULTS.keys)
    options.each_key do |attribute|
      instance_variable_set("@#{attribute}", options[attribute])
    end
  end
end