Sha256: f28e4226b305e10c24f6417cad82b4f7ce5748f7d9eafa1ea0268f8e9e315fb4

Contents?: true

Size: 734 Bytes

Versions: 6

Compression:

Stored size: 734 Bytes

Contents

class Agilibox::SMS::ApplicationSMS
  attr_reader :options

  def initialize(options)
    @options = options
  end

  private

  def action_name
    options[:action_name]
  end

  def t(key, *args)
    if key.start_with?(".")
      path = self.class.to_s.underscore.tr("/", ".")
      key  = "#{path}.#{action_name}#{key}"
    end

    I18n.t(key, *args)
  end

  def sms(data)
    Agilibox::SMS::Message.new(data)
  end

  class << self
    private :new

    def method_missing(m, *args)
      if respond_to_missing?(m)
        new(action_name: m).public_send(m, *args)
      else
        super
      end
    end

    def respond_to_missing?(m, *)
      super || public_instance_methods.include?(m)
    end
  end # class << self
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
agilibox-1.9.11 app/sms/agilibox/sms/application_sms.rb
agilibox-1.9.10 app/sms/agilibox/sms/application_sms.rb
agilibox-1.9.9 app/sms/agilibox/sms/application_sms.rb
agilibox-1.9.8 app/sms/agilibox/sms/application_sms.rb
agilibox-1.9.7 app/sms/agilibox/sms/application_sms.rb
agilibox-1.9.6 app/sms/agilibox/sms/application_sms.rb