Class: Exemplar::Example
- Inherits:
-
Object
- Object
- Exemplar::Example
- Includes:
- Loggable
- Defined in:
- lib/exemplar/example.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, options, block) ⇒ Example
constructor
A new instance of Example.
- #run ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(name, options, block) ⇒ Example
Returns a new instance of Example.
21 22 23 24 25 |
# File 'lib/exemplar/example.rb', line 21 def initialize(name, , block) @name, , @block = name, , block self.class.examples << self end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
19 20 21 |
# File 'lib/exemplar/example.rb', line 19 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/exemplar/example.rb', line 19 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
19 20 21 |
# File 'lib/exemplar/example.rb', line 19 def end |
Class Method Details
.before(*before_methods) ⇒ Object
10 11 12 |
# File 'lib/exemplar/example.rb', line 10 def before(*before_methods) before_callbacks.push *before_methods end |
.before_callbacks ⇒ Object
6 7 8 |
# File 'lib/exemplar/example.rb', line 6 def before_callbacks @before_callbacks ||= [] end |
.examples ⇒ Object
14 15 16 |
# File 'lib/exemplar/example.rb', line 14 def examples @examples ||= [] end |
Instance Method Details
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/exemplar/example.rb', line 27 def run log "Running example #{name}..." block_return = run_before_callbacks && block.call(self) log "Done running example #{name}" block_return rescue Exception => error rescue_error(error) end |