Class: ActiveWebhook::Adapter
- Inherits:
-
Object
- Object
- ActiveWebhook::Adapter
show all
- Extended by:
- Memoist
- Defined in:
- lib/active_webhook/adapter.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**kwargs) ⇒ Adapter
Returns a new instance of Adapter.
92
93
94
95
96
97
|
# File 'lib/active_webhook/adapter.rb', line 92
def initialize(**kwargs)
self.class.attributes.each do |attr_name|
send("#{attr_name}=", kwargs[attr_name]) unless attr_name == :context
end
self.context = kwargs end
|
Class Method Details
.attribute(*attrs) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/active_webhook/adapter.rb', line 46
def attribute(*attrs)
attrs = attrs.map(&:to_sym)
(attrs - attributes).each do |attr_name|
attributes << attr_name.to_sym
attr_accessor attr_name
end
end
|
.attributes ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/active_webhook/adapter.rb', line 9
def attributes
@attributes ||= if self == ActiveWebhook::Adapter
[]
else
ancestors.each_with_object([]) do |ancestor, attrs|
break attrs += ancestor.attributes if ancestor != self && ancestor.respond_to?(:attributes)
attrs
end
end
end
|
.call(*args, **kwargs, &block) ⇒ Object
attrs
end)
# byebug
# x = 1
end
73
74
75
|
# File 'lib/active_webhook/adapter.rb', line 73
def call(*args, **kwargs, &block)
new(*args, **kwargs).call(&block)
end
|
.component_configuration ⇒ Object
85
86
87
|
# File 'lib/active_webhook/adapter.rb', line 85
def component_configuration
configuration.send(component_name)
end
|
.component_name ⇒ Object
77
78
79
|
# File 'lib/active_webhook/adapter.rb', line 77
def component_name
raise NotImplementedError, ".component_name must be implemented."
end
|
Instance Method Details
#attributes ⇒ Object
103
104
105
106
107
|
# File 'lib/active_webhook/adapter.rb', line 103
def attributes
self.class.attributes.each_with_object({}) do |attr_name, h|
h[attr_name] = send(attr_name)
end
end
|
#call ⇒ Object
99
100
101
|
# File 'lib/active_webhook/adapter.rb', line 99
def call
raise NotImplementedError, "#call must be implemented."
end
|
#component_configuration ⇒ Object
113
114
115
|
# File 'lib/active_webhook/adapter.rb', line 113
def component_configuration
self.class.component_configuration
end
|
#configuration ⇒ Object
109
110
111
|
# File 'lib/active_webhook/adapter.rb', line 109
def configuration
self.class.configuration
end
|