Class: Utils::Config::ConfigFile::BlockConfig
- Defined in:
- lib/utils/config/config_file.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.dsl_attributes ⇒ Object
Returns the value of attribute dsl_attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(&block) ⇒ BlockConfig
constructor
A new instance of BlockConfig.
- #to_ruby ⇒ Object
Constructor Details
#initialize(&block) ⇒ BlockConfig
Returns a new instance of BlockConfig.
44 45 46 |
# File 'lib/utils/config/config_file.rb', line 44 def initialize(&block) block and instance_eval(&block) end |
Class Attribute Details
.dsl_attributes ⇒ Object
Returns the value of attribute dsl_attributes.
41 42 43 |
# File 'lib/utils/config/config_file.rb', line 41 def dsl_attributes @dsl_attributes end |
Class Method Details
.config(name, *r, &block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/utils/config/config_file.rb', line 34 def config(name, *r, &block) self.dsl_attributes ||= [] dsl_attributes << name.to_sym dsl_accessor name, *r, &block self end |
.inherited(modul) ⇒ Object
29 30 31 32 |
# File 'lib/utils/config/config_file.rb', line 29 def inherited(modul) modul.extend DSLKit::DSLAccessor super end |
Instance Method Details
#to_ruby ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/utils/config/config_file.rb', line 48 def to_ruby result = '' result << "#{self.class.name[/::([^:]+)\Z/, 1].underscore} do\n" for da in self.class.dsl_attributes result << " #{da} #{Array(__send__(da)).map(&:inspect) * ', '}\n" end result << "end\n" end |