lib/abstract_mapper/builder.rb in abstract_mapper-0.0.1 vs lib/abstract_mapper/builder.rb in abstract_mapper-0.0.2

- old
+ new

@@ -20,12 +20,16 @@ # @!attribute [rw] commands # # @return [AbstractMapper::Commands] The registry of DSL commands # - attr_accessor :commands + attr_writer :commands + def commands + @commands ||= AbstractMapper::Commands + end + end # eigenclass # Updates given node by adding its subnode from the block # # @param [AbstractMapper::Branch] node @@ -59,16 +63,16 @@ # @private def initialize(node, &block) @tree = node @commands = self.class.commands instance_eval(&block) if block_given? - freeze + IceNine.deep_freeze(self) end private # DSL commands def method_missing(name, *args, &block) - node = @commands[name, *args, &block] + node = @commands[name].call(*args, &block) @tree = tree << (node.is_a?(Branch) ? update(node, &block) : node) end def respond_to_missing?(*) true