Module: RightConf::Configurator::ClassMethods

Defined in:
lib/rconf/configurator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#all_settingsObject (readonly)

Access to settings for documentation



30
31
32
# File 'lib/rconf/configurator.rb', line 30

def all_settings
  @all_settings
end

#descObject (readonly)

Description



27
28
29
# File 'lib/rconf/configurator.rb', line 27

def desc
  @desc
end

#keyObject (readonly)

Key associated with configurator



24
25
26
# File 'lib/rconf/configurator.rb', line 24

def key
  @key
end

Instance Method Details

#description(description) ⇒ Object

Store description for documentation

Parameters

description(String)

Description

Return

true

Always return true



52
53
54
55
# File 'lib/rconf/configurator.rb', line 52

def description(description)
  @desc = description
  true
end

#register(key) ⇒ Object

Associate configurator with given key

Parameters

key(Symbol)

Key configurator should be associated with

Return

true

Always return true



39
40
41
42
43
# File 'lib/rconf/configurator.rb', line 39

def register(key)
  ConfiguratorRegistry[key] = self
  @key = key
  true
end

#setting(name, description, options = {}) ⇒ Object

Store setting definition A definition consists of a name, a description and optionally options Possible options are:

:required         => true|false  Whether the setting is required

Parameters

settings(Hash)

Settings descriptions indexed by names

Return

true

Always return true



67
68
69
70
71
72
73
# File 'lib/rconf/configurator.rb', line 67

def setting(name, description, options={})
  @all_settings ||= [{ :name => 'only_if',
                       :description => 'Ruby code that should return true for configurator to proceed',
                       :options => {} }]
  @all_settings << { :name => name, :description => description, :options => options || {} }
  true
end

#updater(val = nil) ⇒ Object

Define code to be run whenever rconf gets updated. Acts as a getter and setter

Parameters

val(Proc)

Code to run when rconf is updated

Return

true

The updater if no parameter is passed, true otherwise



82
83
84
85
86
87
88
89
# File 'lib/rconf/configurator.rb', line 82

def updater(val=nil)
  if val
    @updater = val
    true
  else
    @updater
  end
end