Module: Siamese

Defined in:
lib/siamese.rb,
lib/siamese/message.rb,
lib/siamese/version.rb

Defined Under Namespace

Classes: Message

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.clientObject



35
36
37
# File 'lib/siamese.rb', line 35

def client
  @client ||= Twilio::REST::Client.new(, twilio_auth_token)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Siamese)

    the object that the method was called on



10
11
12
# File 'lib/siamese.rb', line 10

def configure
  yield self
end

.deliver(attributes) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/siamese.rb', line 25

def deliver attributes
  deliveries << attributes
  if Rails.env.production?
    while deliveries.any?
      attributes = deliveries.pop
      client.api..messages.create(**attributes)
    end
  end
end

.method_missing(meth, *args, **kwargs, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/siamese.rb', line 14

def method_missing meth, *args, **kwargs, &block
  template = "sms/#{meth}"
  if ApplicationController.new.lookup_context.exists?(template)
    context = args.first
    options = args.second || {}
    Message.new(template, context, options)
  else
    super
  end
end