Module: Ruote::RubyDsl
- Defined in:
- lib/ruote/reader/ruby_dsl.rb
Overview
:nodoc:
Defined Under Namespace
Classes: BranchContext
Class Method Summary (collapse)
Class Method Details
+ (Object) create_branch(name, attributes, &block)
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/ruote/reader/ruby_dsl.rb', line 120 def self.create_branch(name, attributes, &block) name = name[1..-1] while name[0, 1] == '_' h = attributes.inject({}) { |h1, a| a.is_a?(Hash) ? h1.merge!(a) : h1[a] = nil h1 }.inject({}) { |h1, (k, v)| k = k.is_a?(Regexp) ? k.inspect : k.to_s v = case v when Symbol; v.to_s when Regexp; v.inspect else v end h1[k] = v h1 } c = BranchContext.new(name, h) c.instance_eval(&block) if block c.to_a end |