Sha256: 20e74bfe3557698dcfc80ef5a393bd6c50bf2937ae279ccfd114e64827636790
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
require 'faraday' require_relative "mailstro/version" require_relative "mailstro/configuration" require_relative "mailstro/error" require_relative "mailstro/resource" require_relative "mailstro/delivery" require_relative "mailstro/list_delivery" require_relative "mailstro/list_subscribe" require_relative "mailstro/list_unsubscribe" module Mailstro # Allows us to remove default behaviour during testing. class RealStrategy class << self def deliver(options) Delivery.new(options).deliver end def list_deliver(options) ListDelivery.new(options).deliver end def subscribe(contact_email, list_type, list_name) ListSubscribe.new(contact_email, list_type, list_name).deliver end def unsubscribe(contact_email, list_type, list_name) ListUnsubscribe.new(contact_email, list_type, list_name).deliver end end end class << self attr_accessor :configuration, :strategy end @strategy = RealStrategy @configuration = Configuration.new def self.configure yield(@configuration) && @configuration.validate! end def self.deliver(options) if options[:to].is_a?(Array) @strategy.list_deliver(options) else @strategy.deliver(options) end end def self.subscribe(contact_email, list_type, list_name) @strategy.subscribe(contact_email, list_type, list_name) end def self.unsubscribe(contact_email, list_type, list_name) @strategy.unsubscribe(contact_email, list_type, list_name) end def self.has_delivered?(template_name) TestStrategy.has_delivered?(template_name) end def self.has_subscribed?(contact_email, list_type, list_name) TestStrategy.has_subscribed?(contact_email, list_type, list_name) end def self.has_unsubscribed?(contact_email, list_type, list_name) TestStrategy.has_unsubscribed?(contact_email, list_type, list_name) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mailstro-0.0.8 | lib/mailstro.rb |
mailstro-0.0.7 | lib/mailstro.rb |