Class: Chatterbox::Notification
- Inherits:
-
Object
- Object
- Chatterbox::Notification
- Defined in:
- lib/chatterbox/notification.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #add_rails_info(data) ⇒ Object
- #add_ruby_info(data) ⇒ Object
- #default_info ⇒ Object
- #env ⇒ Object
- #exception_to_notice(hash) ⇒ Object
-
#initialize(message = nil) ⇒ Notification
constructor
A new instance of Notification.
- #normalize_message_to_hash(message) ⇒ Object
- #notice ⇒ Object
- #rails_configuration ⇒ Object
- #ruby_platform ⇒ Object
- #ruby_version ⇒ Object
- #string_to_notice(message) ⇒ Object
Constructor Details
#initialize(message = nil) ⇒ Notification
Returns a new instance of Notification.
7 8 9 |
# File 'lib/chatterbox/notification.rb', line 7 def initialize( = nil) @message = end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/chatterbox/notification.rb', line 5 def @message end |
Instance Method Details
#add_rails_info(data) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/chatterbox/notification.rb', line 55 def add_rails_info(data) data.merge({ :rails_env => rails_configuration.env, :rails_root => rails_configuration.root, :rails_version => rails_configuration.version }) end |
#add_ruby_info(data) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/chatterbox/notification.rb', line 63 def add_ruby_info(data) data.merge({ :ruby_version => ruby_version, :ruby_platform => ruby_platform }) end |
#default_info ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chatterbox/notification.rb', line 28 def default_info default_info = { :summary => "N/A", :environment => env, :ruby_version => ruby_version, :ruby_platform => ruby_platform } default_info = add_ruby_info(default_info) default_info = add_rails_info(default_info) if rails_configuration default_info end |
#env ⇒ Object
78 79 80 |
# File 'lib/chatterbox/notification.rb', line 78 def env ENV.to_hash end |
#exception_to_notice(hash) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chatterbox/notification.rb', line 44 def exception_to_notice(hash) return hash unless hash.key?(:exception) exception = hash[:exception] { :summary => "#{exception.class.name}: #{exception.}", :error_class => exception.class.name, :error_message => exception., :backtrace => exception.backtrace, }.merge(hash) end |
#normalize_message_to_hash(message) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chatterbox/notification.rb', line 17 def () case when Exception === { :exception => } when .respond_to?(:to_hash) .to_hash when .respond_to?(:to_s) string_to_notice(.to_s) end end |
#notice ⇒ Object
11 12 13 14 15 |
# File 'lib/chatterbox/notification.rb', line 11 def notice hash = () hash = exception_to_notice(hash) default_info.merge(hash) end |
#rails_configuration ⇒ Object
82 83 84 |
# File 'lib/chatterbox/notification.rb', line 82 def rails_configuration defined?(Rails) && Rails end |
#ruby_platform ⇒ Object
74 75 76 |
# File 'lib/chatterbox/notification.rb', line 74 def ruby_platform RUBY_PLATFORM end |
#ruby_version ⇒ Object
70 71 72 |
# File 'lib/chatterbox/notification.rb', line 70 def ruby_version RUBY_VERSION end |
#string_to_notice(message) ⇒ Object
40 41 42 |
# File 'lib/chatterbox/notification.rb', line 40 def string_to_notice() { :summary => } end |