Class: Steroids::Support::NoticableMethods::NoticableRuntime
- Inherits:
-
Object
- Object
- Steroids::Support::NoticableMethods::NoticableRuntime
- Defined in:
- lib/steroids/support/noticable_methods.rb
Overview
Noticable runtime class (attached to instance)
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#notices ⇒ Object
readonly
Returns the value of attribute notices.
Instance Method Summary collapse
- #errors? ⇒ Boolean
- #full_messages ⇒ Object (also: #notice, #message)
-
#initialize(concern = [], success_notice: nil) ⇒ NoticableRuntime
constructor
A new instance of NoticableRuntime.
- #merge(noticable) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(concern = [], success_notice: nil) ⇒ NoticableRuntime
Returns a new instance of NoticableRuntime.
71 72 73 74 75 76 |
# File 'lib/steroids/support/noticable_methods.rb', line 71 def initialize(concern = [], success_notice: nil) @concern = concern @success_notice = success_notice.presence || success_notice_placeholder @errors = NoticableCollection.new(:errors) @notices = NoticableCollection.new(:notices) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
69 70 71 |
# File 'lib/steroids/support/noticable_methods.rb', line 69 def errors @errors end |
#notices ⇒ Object (readonly)
Returns the value of attribute notices.
68 69 70 |
# File 'lib/steroids/support/noticable_methods.rb', line 68 def notices @notices end |
Instance Method Details
#errors? ⇒ Boolean
89 90 91 |
# File 'lib/steroids/support/noticable_methods.rb', line 89 def errors? @errors.any? end |
#full_messages ⇒ Object Also known as: notice, message
78 79 80 81 82 83 84 |
# File 'lib/steroids/support/noticable_methods.rb', line 78 def if self.errors? @errors. else @notices..presence || @success_notice end end |
#merge(noticable) ⇒ Object
97 98 99 100 |
# File 'lib/steroids/support/noticable_methods.rb', line 97 def merge(noticable) @notices.merge(noticable.notices) @errors.merge(noticable.errors) end |
#success? ⇒ Boolean
93 94 95 |
# File 'lib/steroids/support/noticable_methods.rb', line 93 def success? !errors? end |