Module: Turnip::StepModule

Extended by:
StepModule
Included in:
StepModule
Defined in:
lib/turnip/step_module.rb

Defined Under Namespace

Modules: DSL Classes: Entry

Instance Method Summary collapse

Instance Method Details

#all_steps_for(*taggings) ⇒ Object



48
49
50
51
52
# File 'lib/turnip/step_module.rb', line 48

def all_steps_for(*taggings)
  modules_for(*taggings).map do |step_module|
    step_module.steps
  end.flatten
end

#clear_module_registryObject



54
55
56
# File 'lib/turnip/step_module.rb', line 54

def clear_module_registry
  module_registry.clear
end

#module_registryObject



66
67
68
# File 'lib/turnip/step_module.rb', line 66

def module_registry
  @module_registry ||= Hash.new { |hash, key| hash[key] = [] }
end

#modules_for(*taggings) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/turnip/step_module.rb', line 58

def modules_for(*taggings)
  taggings.map do |tag|
    module_registry[tag].map do |entry|
      entry.all_modules
    end
  end.flatten.uniq
end

#registered?(module_name) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/turnip/step_module.rb', line 70

def registered?(module_name)
  module_registry.has_key? module_name
end

#step_module(&block) ⇒ Object



82
83
84
85
86
87
# File 'lib/turnip/step_module.rb', line 82

def step_module(&block)
  anon = Module.new
  anon.extend(Turnip::StepModule::DSL)
  anon.module_eval(&block)
  anon
end

#steps_for(tag, &block) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/turnip/step_module.rb', line 74

def steps_for(tag, &block)
  anon = step_module(&block)

  entry = Entry.new(tag, anon, anon.uses_steps)

  module_registry[tag] << entry
end