Class: Foobara::Callback::Registry::Base
- Inherits:
-
Object
- Object
- Foobara::Callback::Registry::Base
show all
- Defined in:
- foobara-0.0.110/projects/callback/src/registry/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#allowed_types ⇒ Object
73
74
75
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 73
def allowed_types
@allowed_types = Block.types
end
|
Instance Method Details
#after ⇒ Object
39
40
41
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 39
def after(...)
register_callback(:after, ...)
end
|
#around ⇒ Object
43
44
45
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 43
def around(...)
register_callback(:around, ...)
end
|
#before ⇒ Object
35
36
37
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 35
def before(...)
register_callback(:before, ...)
end
|
#error ⇒ Object
47
48
49
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 47
def error(...)
register_callback(:error, ...)
end
|
#has_after_callbacks? ⇒ Boolean
59
60
61
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 59
def has_after_callbacks?(*, **)
has_callbacks?(:after, *, **)
end
|
#has_around_callbacks? ⇒ Boolean
63
64
65
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 63
def has_around_callbacks?(*, **)
has_callbacks?(:around, *, **)
end
|
#has_before_callbacks? ⇒ Boolean
55
56
57
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 55
def has_before_callbacks?(*, **)
has_callbacks?(:before, *, **)
end
|
#has_callbacks?(type) ⇒ Boolean
51
52
53
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 51
def has_callbacks?(type, *, **)
!unioned_callback_set_for(*, **)[type].empty?
end
|
#has_error_callbacks? ⇒ Boolean
67
68
69
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 67
def has_error_callbacks?(*, **)
has_callbacks?(:error, *, **)
end
|
#register_callback(type, &callback_block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 9
def register_callback(type, *, **, &callback_block)
unless block_given?
raise ArgumentError, "Must provide a callback block to register"
end
validate_type!(type)
set = specific_callback_set_for(*, **)
set[type] << Block.for(type, callback_block)
end
|
#runner ⇒ Object
5
6
7
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 5
def runner(*, **)
Runner.new(unioned_callback_set_for(*, **))
end
|
#specific_callback_set_for(*_args, **_opts) ⇒ Object
23
24
25
26
27
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 23
def specific_callback_set_for(*_args, **_opts)
raise "subclass responsibility"
end
|
#unioned_callback_set_for(*_args, **_opts) ⇒ Object
29
30
31
32
33
|
# File 'foobara-0.0.110/projects/callback/src/registry/base.rb', line 29
def unioned_callback_set_for(*_args, **_opts)
raise "subclass responsibility"
end
|