Sha256: 9c3afc1c403f3d34b9877dea627eeb646f950873c85c0146c692b76193ed0492

Contents?: true

Size: 847 Bytes

Versions: 4

Compression:

Stored size: 847 Bytes

Contents

module Hypercuke
  # Entry point for the adapter definition API
  def self.topic(topic_name, &block)
    AdapterDefinition.topic topic_name, &block
  end

  module AdapterDefinition
    def self.topic(topic_name, &block)
      Hypercuke.topics.define topic_name
      tb = TopicBuilder.new(topic_name)
      tb.instance_eval &block if block_given?
    end

    class TopicBuilder
      attr_reader :topic_name
      def initialize(topic_name)
        @topic_name = topic_name.to_sym
      end

      # I know the name *says* "layer", but what it *means* is that we
      # should define a step adapter for that layer.
      def layer(layer_name, &block)
        Hypercuke.layers.define layer_name
        klass = Hypercuke::StepAdapters.define( topic_name, layer_name )
        klass.module_eval &block if block_given?
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hypercuke-0.5.2 lib/hypercuke/adapter_definition.rb
hypercuke-0.5.1 lib/hypercuke/adapter_definition.rb
hypercuke-0.5.0 lib/hypercuke/adapter_definition.rb
hypercuke-0.4.1 lib/hypercuke/adapter_definition.rb