Module: Mache::Helpers::Rails::Flash
- Defined in:
- lib/mache/helpers/rails/flash.rb
Overview
The Flash module can be included into page object classes that support flash behaviour.
rubocop:disable Naming/PredicateName
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#has_alert_message?(text) ⇒ Boolean
Tests whether the page has an alert message.
-
#has_error_message?(text) ⇒ Boolean
Tests whether the page has an error message.
-
#has_message?(type, text) ⇒ Boolean
Tests whether the page has a flash message.
-
#has_notice_message?(text) ⇒ Boolean
Tests whether the page has a notice message.
-
#has_success_message?(text) ⇒ Boolean
Tests whether the page has a success message.
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/mache/helpers/rails/flash.rb', line 9 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#has_alert_message?(text) ⇒ Boolean
Tests whether the page has an alert message.
50 51 52 |
# File 'lib/mache/helpers/rails/flash.rb', line 50 def (text) (:alert, text) end |
#has_error_message?(text) ⇒ Boolean
Tests whether the page has an error message.
58 59 60 |
# File 'lib/mache/helpers/rails/flash.rb', line 58 def (text) (:error, text) end |
#has_message?(type, text) ⇒ Boolean
Tests whether the page has a flash message.
24 25 26 27 28 |
# File 'lib/mache/helpers/rails/flash.rb', line 24 def (type, text) css_class = flash[:class] || '' regexp = text.is_a?(String) ? /\A#{Regexp.escape(text)}\Z/ : text css_class.include?(type.to_s) && flash.text.strip =~ regexp end |
#has_notice_message?(text) ⇒ Boolean
Tests whether the page has a notice message.
42 43 44 |
# File 'lib/mache/helpers/rails/flash.rb', line 42 def (text) (:notice, text) end |
#has_success_message?(text) ⇒ Boolean
Tests whether the page has a success message.
34 35 36 |
# File 'lib/mache/helpers/rails/flash.rb', line 34 def (text) (:success, text) end |