Class: RBehave::Story
- Inherits:
-
Object
- Object
- RBehave::Story
- Defined in:
- lib/rbehave/story.rb
Instance Attribute Summary collapse
-
#narrative ⇒ Object
readonly
Returns the value of attribute narrative.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(title, narrative, params = {}, &body) ⇒ Story
constructor
A new instance of Story.
- #run_in(obj) ⇒ Object
Constructor Details
#initialize(title, narrative, params = {}, &body) ⇒ Story
Returns a new instance of Story.
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
#narrative ⇒ Object (readonly)
Returns the value of attribute narrative.
3 4 5 |
# File 'lib/rbehave/story.rb', line 3 def narrative @narrative end |
#title ⇒ Object (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 |