class ActiveWebhook::Adapter
Public Class Methods
attribute(*attrs)
click to toggle source
# File lib/active_webhook/adapter.rb, line 46 def attribute(*attrs) # Module.new.tap do |m| # Using anonymous modules so that super can be used to extend accessor methods # include m attrs = attrs.map(&:to_sym) (attrs - attributes).each do |attr_name| attributes << attr_name.to_sym # m.attr_accessor attr_name attr_accessor attr_name # end end end
attributes()
click to toggle source
# 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 # # byebug # # puts ['start', self, @attributes].join(', ') # @attributes ||= ancestors.each_with_object([]) do |ancestor, attrs| # # break attrs if ancestor == ActiveWebhook::Adapter # if ancestor != self # if ancestor.respond_to?(:attributes) # break attrs += ancestor.attributes # end # end # attrs # # puts ['searching', ancestor, attrs].join(', ') # # byebug # # break attrs if ancestor == ActiveWebhook::Adapter # # break attrs if ancestor != self && ancestor.respond_to?(:attributes)) # # byebug # # attrs # end # puts ['finished', self, @attributes].join(' ,') # # byebug # # @attributes ||= [] # @attributes end
call(*args, **kwargs, &block)
click to toggle source
attrs end) # byebug # x = 1
end
# File lib/active_webhook/adapter.rb, line 73 def call(*args, **kwargs, &block) new(*args, **kwargs).call(&block) end
component_configuration()
click to toggle source
# File lib/active_webhook/adapter.rb, line 85 def component_configuration configuration.send(component_name) end
component_name()
click to toggle source
# File lib/active_webhook/adapter.rb, line 77 def component_name raise NotImplementedError, ".component_name must be implemented." end
configuration()
click to toggle source
# File lib/active_webhook/adapter.rb, line 81 def configuration ActiveWebhook.configuration end
new(**kwargs)
click to toggle source
# 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 #.symbolize_keys! #with_indifferent_access end
Public Instance Methods
attributes()
click to toggle source
# 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()
click to toggle source
# File lib/active_webhook/adapter.rb, line 99 def call raise NotImplementedError, "#call must be implemented." end
component_configuration()
click to toggle source
# File lib/active_webhook/adapter.rb, line 113 def component_configuration self.class.component_configuration end
configuration()
click to toggle source
# File lib/active_webhook/adapter.rb, line 109 def configuration self.class.configuration end