Class: RSpec::Core::Hooks::Hook

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/core/hooks.rb

Direct Known Subclasses

AfterHook, AroundHook, BeforeHook

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, &block) ⇒ Hook

Returns a new instance of Hook.



8
9
10
11
# File 'lib/rspec/core/hooks.rb', line 8

def initialize(options, &block)
  @options = options
  @block = block
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/rspec/core/hooks.rb', line 6

def options
  @options
end

Instance Method Details

#callObject



21
22
23
# File 'lib/rspec/core/hooks.rb', line 21

def call
  @block.call
end

#options_apply?(example_or_group) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/rspec/core/hooks.rb', line 13

def options_apply?(example_or_group)
  !example_or_group || example_or_group.apply?(:all?, options)
end

#to_procObject



17
18
19
# File 'lib/rspec/core/hooks.rb', line 17

def to_proc
  @block
end