Sha256: 050eb2b87cde093c32b6ce6a56f8138740675aec2f511988491aed64cbd97590

Contents?: true

Size: 660 Bytes

Versions: 2

Compression:

Stored size: 660 Bytes

Contents

module Smess
  class Auto < Output

    attr_accessor :output_name

    def validate_config
    end

    def deliver
      out = output_for sms.to
      out.deliver.merge({sent_with: output_name})
    end

    def get_output_name_for_msisdn(msisdn)
      3.downto(0).each do |index|
        return Smess.config.output_by_country_code[msisdn[0..index]] if Smess.config.output_by_country_code.key? msisdn[0..index]
      end
      Smess.config.default_output
    end

    def output_for(msisdn)
      output_name = get_output_name_for_msisdn(msisdn)
      output = Smess.named_output_instance( output_name )
      output.sms = sms
      output
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smess-2.0.1 lib/smess/outputs/auto.rb
smess-2.0 lib/smess/outputs/auto.rb