Module: AppConfig
Instance Method Summary collapse
-
#config(&block) ⇒ Object
And we define a wrapper for the configuration block, that we’ll use to set up our set of options.
-
#parameter(*names) ⇒ Object
Appdata provides a basic single-method DSL with .parameter method being used to define a set of available settings.
Instance Method Details
#config(&block) ⇒ Object
And we define a wrapper for the configuration block, that we’ll use to set up our set of options
27 28 29 |
# File 'lib/command_post/config/app_config.rb', line 27 def config(&block) instance_eval &block end |
#parameter(*names) ⇒ Object
Appdata provides a basic single-method DSL with .parameter method being used to define a set of available settings. This method takes one or more symbols, with each one being a name of the configuration option.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/command_post/config/app_config.rb', line 11 def parameter(*names) names.each do |name| attr_accessor name # For each given symbol we generate accessor method that sets option's # value being called with an argument, or returns option's current value # when called without arguments define_method name do |*values| value = values.first value ? self.send("#{name}=", value) : instance_variable_get("@#{name}") end end end |