Method: ADSL::Parser::ASTNode#optimize
- Defined in:
- lib/adsl/parser/ast_nodes.rb
#optimize ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/adsl/parser/ast_nodes.rb', line 59 def optimize copy = self.dup children = self.class.container_for_fields.map{ |field_name| [field_name, copy.send(field_name)] } until children.empty? child_name, child = children.pop new_value = child.respond_to?(:optimize) ? child.optimize : child.dup copy.send "#{child_name}=", new_value unless new_value.equal? child end copy end |