Class: Pushpop::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/pushpop/step.rb

Defined Under Namespace

Classes: ERBContext

Constant Summary collapse

TEMPLATES_DIRECTORY =
File.expand_path('templates', Dir.pwd)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, plugin = nil, &block) ⇒ Step

Returns a new instance of Step.



27
28
29
30
31
# File 'lib/pushpop/step.rb', line 27

def initialize(name=nil, plugin=nil, &block)
  self.name = name || plugin || Pushpop.random_name
  self.plugin = plugin
  self.block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



25
26
27
# File 'lib/pushpop/step.rb', line 25

def block
  @block
end

#nameObject

Returns the value of attribute name.



23
24
25
# File 'lib/pushpop/step.rb', line 23

def name
  @name
end

#pluginObject

Returns the value of attribute plugin.



24
25
26
# File 'lib/pushpop/step.rb', line 24

def plugin
  @plugin
end

Instance Method Details

#run(last_response = nil, step_responses = nil) ⇒ Object



38
39
40
# File 'lib/pushpop/step.rb', line 38

def run(last_response=nil, step_responses=nil)
  self.instance_exec(last_response, step_responses, &block)
end

#template(filename, response, step_responses = {}, directory = TEMPLATES_DIRECTORY) ⇒ Object



33
34
35
36
# File 'lib/pushpop/step.rb', line 33

def template(filename, response, step_responses={}, directory=TEMPLATES_DIRECTORY)
  erb_context = ERBContext.new(response, step_responses)
  ERB.new(get_template_contents(filename, directory)).result(erb_context.get_binding)
end