Sha256: 5221e8e5cd2d6c8733cd93b15828618f907ba6ec22f9690e41ae205b090401b0
Contents?: true
Size: 696 Bytes
Versions: 4
Compression:
Stored size: 696 Bytes
Contents
require 'grokdown' module Grokdown module Consuming def self.extended(base) base.send(:include,InstanceMethods) end def consumes?(node) @consumables ||= {} @consumables.has_key?(node.class) end def consumes(mapping={}) @consumables = mapping end def consume(inst,node) @consumables ||= {} inst.send(@consumables.fetch(node.class),node) rescue KeyError raise ArgumentError, "#{inst.class} cannot consume #{node.class}" end module InstanceMethods def consumes?(node) self.class.consumes?(node) end def consume(node) self.class.consume(self,node) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
grokdown-0.2.1 | lib/grokdown/consuming.rb |
grokdown-0.2.0 | lib/grokdown/consuming.rb |
grokdown-0.1.1 | lib/grokdown/consuming.rb |
grokdown-0.1.0 | lib/grokdown/consuming.rb |