Class: Capable::Configuration

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

Constant Summary collapse

OPTIONS =
[:verbose].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

def initialize
  # these defaults can be overridden in the Tokengen.config block
  @verbose = false
end

Instance Attribute Details

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/capable/configuration.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#[](option) ⇒ Object

Allows config options to be read like a hash

Parameters:

  • option (Symbol)

    Key for a given attribute



16
17
18
# File 'lib/capable/configuration.rb', line 16

def [](option)
  send(option)
end

#merge(hash) ⇒ Object

Returns a hash of all configurable options merged with hash

Parameters:

  • hash (Hash)

    A set of configuration options that will take precedence over the defaults



31
32
33
# File 'lib/capable/configuration.rb', line 31

def merge(hash)
  to_hash.merge(hash)
end

#to_hashObject

Returns a hash of all configurable options



21
22
23
24
25
26
# File 'lib/capable/configuration.rb', line 21

def to_hash
  OPTIONS.inject({}) do |hash, option|
    hash[option.to_sym] = self.send(option)
    hash
  end
end