Sha256: 16f8cc99cb45b115dd7bd5f402610bae84b97821537c8c34fa2510598538acc6
Contents?: true
Size: 637 Bytes
Versions: 7
Compression:
Stored size: 637 Bytes
Contents
module Hanuman class LinkFactory Registry = { simple: ->(from_stage, *into_stage){ DirectedLink.new(from_stage, *into_stage) } } class << self def connect(label, from_stage, *into_stage) Registry[label].call(from_stage, *into_stage) end def register(label, factory_method) Registry[label] = factory_method end end end class DirectedLink attr_accessor :from, :into def initialize(from, into) @from = from @into = into end def to_s "#<#{self.class}(#{from.to_s} -> #{into.to_s})>" end end end
Version data entries
7 entries across 7 versions & 2 rubygems