Class: ServiceObjects::Parsers::Notification
- Inherits:
-
Object
- Object
- ServiceObjects::Parsers::Notification
- Defined in:
- lib/service_objects/parsers/notification.rb
Overview
Parses and decorates a string, describing a notification
Class Method Summary collapse
-
.initialize(source) ⇒ ServiceObjects::Parsers::Notification
Initializes the object from source string.
Instance Method Summary collapse
-
#args ⇒ Array<String>
The list of published values.
-
#error? ⇒ Boolean
Checks whether a notification reports an error.
-
#exception ⇒ String
The type of exception to be raised and catched by service object.
-
#name ⇒ String
The name for the parsed value.
-
#new(source) ⇒ ServiceObjects::Parsers::Notification
Initializes the object from source string.
-
#non_messages ⇒ Array<String>
The list of pulished values except for messages.
-
#order ⇒ 0, 1
Returns value to order notifications by.
-
#publish_messages? ⇒ Boolean
Checks whether a notification publishes messages.
Class Method Details
.initialize(source) ⇒ ServiceObjects::Parsers::Notification
Initializes the object from source string
26 27 28 |
# File 'lib/service_objects/parsers/notification.rb', line 26 def initialize(source) @source = source.to_s end |
Instance Method Details
#args ⇒ Array<String>
The list of published values
44 45 46 |
# File 'lib/service_objects/parsers/notification.rb', line 44 def args @args ||= Array(list[1..-1]) end |
#error? ⇒ Boolean
Checks whether a notification reports an error
56 57 58 |
# File 'lib/service_objects/parsers/notification.rb', line 56 def error? name == "error" end |
#exception ⇒ String
The type of exception to be raised and catched by service object
38 39 40 |
# File 'lib/service_objects/parsers/notification.rb', line 38 def exception @exception ||= name.camel_case end |
#name ⇒ String
The name for the parsed value
32 33 34 |
# File 'lib/service_objects/parsers/notification.rb', line 32 def name @name ||= list.first end |
#new(source) ⇒ ServiceObjects::Parsers::Notification
Initializes the object from source string
26 27 28 |
# File 'lib/service_objects/parsers/notification.rb', line 26 def initialize(source) @source = source.to_s end |
#non_messages ⇒ Array<String>
The list of pulished values except for messages
50 51 52 |
# File 'lib/service_objects/parsers/notification.rb', line 50 def @non_messages ||= args.reject { |item| item == "messages" } end |
#order ⇒ 0, 1
Returns value to order notifications by
69 70 71 |
# File 'lib/service_objects/parsers/notification.rb', line 69 def order @order = error? ? 1 : 0 end |
#publish_messages? ⇒ Boolean
Checks whether a notification publishes messages
62 63 64 |
# File 'lib/service_objects/parsers/notification.rb', line 62 def args.include? "messages" end |