Module: SmsOnRails::ActsAsDeliverable::InstanceMethods

Defined in:
lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb

Instance Method Summary collapse

Instance Method Details

#deliver(options = {}) ⇒ Object

Return true if delivery was successful If unsuccessful, only raise fatal exceptions, and return false otherwise

Options

fatal_exception - specify the fatal exception Class to throw. To dismiss all exceptions, set to nil. Defaults to acts_as_deliverable_options specified error - add an error to the objects base if delivery failed



51
52
53
54
55
56
57
58
59
# File 'lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb', line 51

def deliver(options={})
  deliver!(options)
rescue Exception => exc
  log_delivery_error(exc)
  fatal_exception = acts_as_deliverable_options.merge(options)[:fatal_exception]
  raise exc if fatal_exception && exc.is_a?(fatal_exception)
  self.errors.add_to_base(delivery_error_message(exc, options))
  false
end

#deliver!(options = {}) ⇒ Object

Deliver and mark the status fields approriately



62
63
64
# File 'lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb', line 62

def deliver!(options={})
  lock_record_and_execute { deliver_message(options) }
end

#deliver_message(options = {}) ⇒ Object

Deliver message should be overridden by the class to perform any functionality



70
71
72
# File 'lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb', line 70

def deliver_message(options={})
  raise(acts_as_deliverable_options[:fatal_exception]||Exception).new "Overwrite deliver_message in base class to perform the actual delivery"
end

#delivered?Boolean

Returns:

  • (Boolean)


66
# File 'lib/sms_on_rails/activerecord_extensions/acts_as_deliverable.rb', line 66

def delivered?; already_processed?; end