Module: SmsOnRails::ModelSupport::Outbound

Included in:
Outbound
Defined in:
lib/sms_on_rails/model_support/outbound.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sms_on_rails/model_support/outbound.rb', line 8

def self.included(base)

  base.has_a_sms_service_provider

  base.acts_as_deliverable :fatal_exception => SmsOnRails::FatalSmsError,
                           :error => 'Unable to send message.'


  base.acts_as_substitutable :draft_message,
                      :phone_number_digits  => :phone_number_digits,
                      :phone_number  => Proc.new{|record| record.phone_number.human_display },
                      :sender_name   => :sender_name

  base.send :alias_method, :full_message,      :substituted_draft_message
  base.send :alias_method, :send_immediately,  :deliver
  base.send :alias_method, :send_immediately!, :deliver!

  base.send :cattr_accessor, :default_options

  base.send :accepts_nested_attributes_for, :phone_number
  
  base.send :include, InstanceMethods
  base.send :extend,  ClassMethods
end