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.
61 62 63 |
# File 'lib/utils/config/config_file.rb', line 61 def initialize(&block) block and instance_eval(&block) end |
Class Attribute Details
.dsl_attributes ⇒ Object
Returns the value of attribute dsl_attributes.
58 59 60 |
# File 'lib/utils/config/config_file.rb', line 58 def dsl_attributes @dsl_attributes end |
Class Method Details
.config(name, *r, &block) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/utils/config/config_file.rb', line 51 def config(name, *r, &block) self.dsl_attributes ||= [] dsl_attributes << name.to_sym dsl_accessor name, *r, &block self end |
.inherited(modul) ⇒ Object
46 47 48 49 |
# File 'lib/utils/config/config_file.rb', line 46 def inherited(modul) modul.extend DSLKit::DSLAccessor super end |
Instance Method Details
#to_ruby ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/utils/config/config_file.rb', line 65 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 |