Module: ActionMessageTexter::DeliveryMethods::ClassMethods
- Defined in:
- lib/action_message_texter/delivery_methods.rb
Instance Method Summary collapse
- #add_delivery_method(symbol, klass, options = {}) ⇒ Object
- #wrap_delivery_behavior(message, method = nil, options = {}) ⇒ Object
Instance Method Details
#add_delivery_method(symbol, klass, options = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/action_message_texter/delivery_methods.rb', line 19 def add_delivery_method(symbol, klass, = {}) class_attribute("#{symbol}_settings".to_sym) unless respond_to?("#{symbol}_settings".to_sym) send("#{symbol}_settings=".to_sym, ) self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze end |
#wrap_delivery_behavior(message, method = nil, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/action_message_texter/delivery_methods.rb', line 25 def wrap_delivery_behavior(, method = nil, = {}) method ||= delivery_method .delivery_handler = self case method when NilClass raise 'Delivery method cannot be nil' when Symbol if klass = delivery_methods[method] .delivery_method(klass, (send("#{method}_settings") || {}).merge()) else raise "Invalid delivery method #{method.inspect}" end else .delivery_method(method) end .raise_delivery_errors = raise_delivery_errors end |