Class: Alf::Support::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/alf-support/alf/support/config.rb

Direct Known Subclasses

Database::Options

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h = {}) ⇒ Config

Creates a default options instance



33
34
35
# File 'lib/alf-support/alf/support/config.rb', line 33

def initialize(h = {})
  install_options_from_hash(h)
end

Class Method Details

.delegation_methodsObject



5
6
7
# File 'lib/alf-support/alf/support/config.rb', line 5

def self.delegation_methods
  public_instance_methods(false).reject{|m| m.to_s =~ /=$/ }
end

.helpers(to = :config) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/alf-support/alf/support/config.rb', line 9

def self.helpers(to = :config)
  meths = delegation_methods
  Module.new do
    meths.each do |m|
      define_method(m){|*args, &bl| self.send(to).send(m, *args, &bl) }
    end
  end
end

Instance Method Details

#merge(h) ⇒ Object

Merge with another options from a hash



38
39
40
# File 'lib/alf-support/alf/support/config.rb', line 38

def merge(h)
  dup.install_options_from_hash(h)
end