Class: MetaSms::SmsLogging
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- MetaSms::SmsLogging
- Defined in:
- lib/meta_sms/sms_logging.rb
Overview
This is an ActiveRecord class. It is used to save sms log in db.
Class Method Summary collapse
- .get_sms_logging_object(result, options, error) ⇒ Object
-
.log_sms(result, options, error) ⇒ Object
Description of method.
Class Method Details
.get_sms_logging_object(result, options, error) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/meta_sms/sms_logging.rb', line 22 def self.get_sms_logging_object(result, , error) sms_logging_object = { message_text: [:message_text], mobile_number: [:mobile_number], error_message: error.try(:message) } = [:metadata] sms_logging_object[:metadata] = {:response => result}.as_json sms_logging_object[:metadata].merge() if .present? sms_logging_object end |
.log_sms(result, options, error) ⇒ Object
Description of method
14 15 16 17 18 19 20 |
# File 'lib/meta_sms/sms_logging.rb', line 14 def self.log_sms(result, , error) if ActiveRecord::Base.connection.table_exists? self.table_name SmsLogging.create( SmsLogging.get_sms_logging_object(result, , error) ) else raise StandardError.new "No table exists. Please run 'rails g meta_sms:migrations_for_logger' and then run 'rake db:migrate'. To disable this warning, make config.logging=false, in config/initializers/meta_sms.rb." end end |