Class: RBehave::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/rbehave/story.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, narrative, params = {}, &body) ⇒ Story

Returns a new instance of Story.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/rbehave/story.rb', line 5

def initialize(title, narrative, params = {}, &body)
  raise(ArgumentError, 'A story needs a body') unless block_given?
  @body = body
  @title = title
  @narrative = narrative
  @params = params
end

Instance Attribute Details

#narrativeObject (readonly)

Returns the value of attribute narrative.



3
4
5
# File 'lib/rbehave/story.rb', line 3

def narrative
  @narrative
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/rbehave/story.rb', line 3

def title
  @title
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/rbehave/story.rb', line 13

def [](key)
  @params[key]
end

#run_in(obj) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rbehave/story.rb', line 17

def run_in(obj)
  begin
    obj.instance_eval(&@body)
  rescue Exception => e
    p e
    raise
  end
end