Class: CmSms::Messenger

Inherits:
Object
  • Object
show all
Defined in:
lib/cm_sms/messenger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Messenger

Returns a new instance of Messenger.



6
7
8
9
10
11
12
13
14
# File 'lib/cm_sms/messenger.rb', line 6

def initialize(attributes = {})
  self.class.default_params ||= {}
  
  @from = attributes[:from] || self.class.default_params[:from]
  @to   = attributes[:to] || self.class.default_params[:to]
  @dcs  = attributes[:dcs] || self.class.default_params[:dcs]
  @body = attributes[:body]
  @reference = attributes[:reference]
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/cm_sms/messenger.rb', line 4

def body
  @body
end

#dcsObject

Returns the value of attribute dcs.



4
5
6
# File 'lib/cm_sms/messenger.rb', line 4

def dcs
  @dcs
end

#fromObject

Returns the value of attribute from.



4
5
6
# File 'lib/cm_sms/messenger.rb', line 4

def from
  @from
end

#referenceObject

Returns the value of attribute reference.



4
5
6
# File 'lib/cm_sms/messenger.rb', line 4

def reference
  @reference
end

#toObject

Returns the value of attribute to.



4
5
6
# File 'lib/cm_sms/messenger.rb', line 4

def to
  @to
end

Class Method Details

.default(hash = {}) ⇒ Object



45
46
47
48
# File 'lib/cm_sms/messenger.rb', line 45

def self.default(hash = {})
  self.default_params = CmSms.config.defaults.merge(hash).freeze
  default_params
end

.default_paramsObject



37
38
39
# File 'lib/cm_sms/messenger.rb', line 37

def self.default_params
  @@default_params ||= CmSms.config.defaults
end

.default_params=(params = {}) ⇒ Object



41
42
43
# File 'lib/cm_sms/messenger.rb', line 41

def self.default_params=(params = {})
  @@default_params = params
end

.method_missing(method_name, *args) ⇒ Object

:nodoc:



25
26
27
28
29
30
31
# File 'lib/cm_sms/messenger.rb', line 25

def self.method_missing(method_name, *args) # :nodoc:
  if new.respond_to?(method_name.to_s)
    CmSms::MessageDelivery.new(self, method_name, *args)
  else
    super
  end
end

.respond_to_missing?(method_name, *args) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


33
34
35
# File 'lib/cm_sms/messenger.rb', line 33

def self.respond_to_missing?(method_name, *args) # :nodoc:
  new.respond_to?(method_name.to_s) || super
end

Instance Method Details

#content(attributes = {}) ⇒ Object



16
17
18
19
# File 'lib/cm_sms/messenger.rb', line 16

def content(attributes = {})
  attributes.each { |attr, value| send("#{attr}=", value) }
  self
end

#messageObject



21
22
23
# File 'lib/cm_sms/messenger.rb', line 21

def message
  @message ||= CmSms::Message.new(from: from, to: to, dcs: dcs, body: body, reference: reference)
end