Class: Configurability::SettingInstaller

Inherits:
Object
  • Object
show all
Extended by:
Loggability
Defined in:
lib/configurability/setting_installer.rb

Overview

Methods for declaring config methods and constants inside a configurability block.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ SettingInstaller

Create a new Generator that can be used to add configuration methods and constants to the specified target object.



19
20
21
22
# File 'lib/configurability/setting_installer.rb', line 19

def initialize( target )
	@target = target
	@lexed = nil
end

Instance Attribute Details

#targetObject (readonly)

The target object



27
28
29
# File 'lib/configurability/setting_installer.rb', line 27

def target
  @target
end

Instance Method Details

#setting(name, **options, &block) ⇒ Object

Declare a config setting with the specified name.



31
32
33
34
35
36
37
38
# File 'lib/configurability/setting_installer.rb', line 31

def setting( name, **options, &block )
	self.log.debug "  adding %s setting to %p" % [ name, self.target ]

	options[:alias] = Array( options[:alias] )
	self.add_comment_accessor( name, options )
	self.add_setting_accessors( name, options, &block )
	self.add_default( name, options[:default] )
end

#setting_default(name, new_default) ⇒ Object

Declare a new default for the setting with the specified name.



42
43
44
# File 'lib/configurability/setting_installer.rb', line 42

def setting_default( name, new_default )
	self.add_default( name, new_default )
end