Class: Nina::Builder::Callbacks
- Inherits:
-
Object
- Object
- Nina::Builder::Callbacks
show all
- Defined in:
- lib/nina/builder/callbacks.rb
Overview
Utility to get user defined callbacks
Instance Method Summary
collapse
Constructor Details
#initialize(allow_list, atts = {}) ⇒ Callbacks
Returns a new instance of Callbacks.
7
8
9
10
|
# File 'lib/nina/builder/callbacks.rb', line 7
def initialize(allow_list, atts = {})
@allow_list = allow_list
@atts = atts
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, **kwargs, &block) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/nina/builder/callbacks.rb', line 16
def method_missing(method, *args, **kwargs, &block)
return super unless @allow_list.include?(method)
@atts[method] unless block
@atts[method] ||= []
@atts[method] << block
end
|
Instance Method Details
#copy ⇒ Object
12
13
14
|
# File 'lib/nina/builder/callbacks.rb', line 12
def copy
Callbacks.new(@allow_list, to_h.dup)
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
24
25
26
|
# File 'lib/nina/builder/callbacks.rb', line 24
def respond_to_missing?(method, include_private = false)
super
end
|
#to_h ⇒ Object
28
29
30
|
# File 'lib/nina/builder/callbacks.rb', line 28
def to_h
@atts
end
|