Module: Envandle::AsDsl
- Included in:
- Elements::Gemfile::Dsl, Elements::GroupBlock::Dsl
- Defined in:
- lib/envandle/as_dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(mod) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/envandle/as_dsl.rb', line 3 def self.extended(mod) mod.class_eval do def initialize(e) @element = e end end end |
Instance Method Details
#dsl_method(name) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/envandle/as_dsl.rb', line 11 def dsl_method(name) name = name.to_s class_name = Envandle.pascal(name) block_class_name = "#{class_name}Block" define_method name do |*args, &block| klass = ::Envandle::Elements.const_get(block ? block_class_name : class_name) o = klass.new(::Envandle.loc, @element, *args, &block) @element << o o.draw end end |