Sha256: 0882723aa195f091d8d2b716358ddd3ed6d66f2c9b664a80e9b77346e7a48976

Contents?: true

Size: 772 Bytes

Versions: 10

Compression:

Stored size: 772 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 send_feedback(message_sid)
      out = output_for sms.to
      out.send_feedback(message_sid)
    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

10 entries across 10 versions & 1 rubygems

Version Path
smess-3.3.0 lib/smess/outputs/auto.rb
smess-3.2.0 lib/smess/outputs/auto.rb
smess-3.1.2 lib/smess/outputs/auto.rb
smess-3.1.1 lib/smess/outputs/auto.rb
smess-3.1.0 lib/smess/outputs/auto.rb
smess-3.0.0 lib/smess/outputs/auto.rb
smess-2.3.0 lib/smess/outputs/auto.rb
smess-2.2.1 lib/smess/outputs/auto.rb
smess-2.2.0 lib/smess/outputs/auto.rb
smess-2.1.0 lib/smess/outputs/auto.rb