Class: Hypercuke::TopicModule

Inherits:
Module
  • Object
show all
Defined in:
lib/hypercuke/step_adapters.rb,
lib/hypercuke/step_adapters.rb

Overview

So, a TopicModule is (a) a namespace for holding step adapters, and (b) a slightly specialized type of Module that knows enough to be able to fetch step adapters.

Instance Method Summary collapse

Instance Method Details

#define_step_adapter(layer_name) ⇒ Object



108
109
110
111
112
113
# File 'lib/hypercuke/step_adapters.rb', line 108

def define_step_adapter(layer_name)
  fetch_step_adapter(layer_name)
rescue Hypercuke::StepAdapterNotDefinedError
  const_name = MiniInflector.camelize(layer_name)
  const_set const_name, Class.new(StepAdapter)
end

#fetch_step_adapter(layer_name) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/hypercuke/step_adapters.rb', line 57

def fetch_step_adapter(layer_name)
  # FIXME: cyclomatic complexity
  Hypercuke.layers.validate(layer_name) do
    fail LayerNotDefinedError, "Layer not defined: #{layer_name}"
  end
  validate_step_adapter \
    begin
      const_get( MiniInflector.camelize(layer_name) )
    rescue NameError => e
      raise Hypercuke::StepAdapterNotDefinedError.wrap(e)
    end
end