module ActionTexter class Message include DeliveryMethods attr_accessor :from, :to, :body, :reference, :delivery_handler attr_reader :delivery_method, :delivery_options def initialize(attributes = {}) @from = attributes[:from] @to = attributes[:to] @body = attributes[:body] @reference = attributes[:reference] wrap_delivery_behavior!(self, ActionTexter.config.delivery_method) end def deliver @delivery_method.deliver(self) # request.perform if valid? end def deliver! deliver end def delivery_method(method = nil, opts = {}) unless method @delivery_method else @delivery_method = method.new(opts) end end end end