Class: ActionTexter::Messenger

Inherits:
Object
  • Object
show all
Defined in:
lib/action_texter/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.



5
6
7
8
9
10
11
12
# File 'lib/action_texter/messenger.rb', line 5

def initialize(attributes = {})
  self.class.default_params ||= {}

  @from = attributes[:from] || self.class.default_params[:from]
  @to   = attributes[:to] || self.class.default_params[:to]
  @body = attributes[:body]
  @reference = attributes[:reference]
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/action_texter/messenger.rb', line 3

def body
  @body
end

#dcsObject

Returns the value of attribute dcs.



3
4
5
# File 'lib/action_texter/messenger.rb', line 3

def dcs
  @dcs
end

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/action_texter/messenger.rb', line 3

def from
  @from
end

#referenceObject

Returns the value of attribute reference.



3
4
5
# File 'lib/action_texter/messenger.rb', line 3

def reference
  @reference
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/action_texter/messenger.rb', line 3

def to
  @to
end

Class Method Details

.default(hash = {}) ⇒ Object



43
44
45
46
# File 'lib/action_texter/messenger.rb', line 43

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

.default_paramsObject



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

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

.default_params=(params = {}) ⇒ Object



39
40
41
# File 'lib/action_texter/messenger.rb', line 39

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

.method_missing(method_name, *args) ⇒ Object

:nodoc:



23
24
25
26
27
28
29
# File 'lib/action_texter/messenger.rb', line 23

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

.respond_to_missing?(method_name, *args) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


31
32
33
# File 'lib/action_texter/messenger.rb', line 31

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

Instance Method Details

#content(attributes = {}) ⇒ Object



14
15
16
17
# File 'lib/action_texter/messenger.rb', line 14

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

#messageObject



19
20
21
# File 'lib/action_texter/messenger.rb', line 19

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