Class: RSpec::Core::Hooks::Hook
- Inherits:
-
Object
- Object
- RSpec::Core::Hooks::Hook
show all
- Defined in:
- lib/rspec/core/hooks.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options, &block) ⇒ Hook
Returns a new instance of Hook.
9
10
11
12
13
|
# File 'lib/rspec/core/hooks.rb', line 9
def initialize(options, &block)
@options = options
raise "no block given for #{display_name}" unless block
@block = block
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7
8
9
|
# File 'lib/rspec/core/hooks.rb', line 7
def options
@options
end
|
Instance Method Details
#call ⇒ Object
23
24
25
|
# File 'lib/rspec/core/hooks.rb', line 23
def call
@block.call
end
|
#display_name ⇒ Object
27
28
29
|
# File 'lib/rspec/core/hooks.rb', line 27
def display_name
self.class.name.split('::').last.gsub('Hook','').downcase << " hook"
end
|
#options_apply?(example_or_group) ⇒ Boolean
15
16
17
|
# File 'lib/rspec/core/hooks.rb', line 15
def options_apply?(example_or_group)
example_or_group.all_apply?(options)
end
|
#to_proc ⇒ Object
19
20
21
|
# File 'lib/rspec/core/hooks.rb', line 19
def to_proc
@block
end
|