class Statusboard::DSL::DSLBase
Public Class Methods
new(&block)
click to toggle source
Default constructor. Executes the given block within its own context, so the block contents behave as a DSL
.
# File lib/statusboard/dsl/base.rb, line 35 def initialize(&block) instance_eval &block end
setter(*method_names)
click to toggle source
Automatically creates DSL-like setters for the specified fields. Fields must be specified as symbols.
# File lib/statusboard/dsl/base.rb, line 7 def self.setter(*method_names) method_names.each do |name| send :define_method, name do |data| instance_variable_set "@#{name}".to_sym, data end end end
setter_with_default_value(method_name, default_value)
click to toggle source
Automatically creates a DSL-like setter for a specified field. If the setter is called by the *user without an argument*, the specified default value will be used as the value.
The method will NOT use the specified value as a default value for the field. If a default value is needed, the field should be set in the constructor.
Attributes¶ ↑
-
method_name
- Name of the field for which a setter should be created -
default_value
- Default value of the argument which is used if the method is called without an argument
# File lib/statusboard/dsl/base.rb, line 27 def self.setter_with_default_value(method_name, default_value) send :define_method, method_name do |data = default_value| instance_variable_set "@#{method_name}".to_sym, data end end