Sha256: 60938bb778f4068b185a8b87379ed11036b622adc560997f237de76d2eb40b20

Contents?: true

Size: 527 Bytes

Versions: 3

Compression:

Stored size: 527 Bytes

Contents

module Minitext
  class WhitelistProxy
    attr_reader :whitelist, :gateway
    
    def initialize(params)
      @whitelist = Array(params.fetch(:whitelist) {Hash.new})
      @gateway = params.fetch(:gateway) {TestGateway.new}
    end

    def deliver(message)
      gateway.deliver(message) if whitelisted?(message.to)
    end

    def method_missing(method, *args, &block)
      gateway.send(method, *args, &block)
    end

    protected

    def whitelisted?(recipient)
      whitelist.include?(recipient)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minitext-0.0.8 lib/minitext/whitelist_proxy.rb
minitext-0.0.7 lib/minitext/whitelist_proxy.rb
minitext-0.0.6 lib/minitext/whitelist_proxy.rb