Class: Toolsmith::Views::FlashDiv
- Defined in:
- lib/toolsmith/views/flash_div.rb
Constant Summary collapse
- LEVEL_MAPPING =
{ error: :error, alert: :error, success: :success, notice: :info }
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#view_level ⇒ Object
readonly
Returns the value of attribute view_level.
Attributes inherited from Base
Instance Method Summary collapse
- #close_link ⇒ Object
- #close_link_text ⇒ Object
- #container ⇒ Object
-
#initialize(context, level) ⇒ FlashDiv
constructor
A new instance of FlashDiv.
- #to_s ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(context, level) ⇒ FlashDiv
Returns a new instance of FlashDiv.
14 15 16 17 18 |
# File 'lib/toolsmith/views/flash_div.rb', line 14 def initialize(context, level) super(context) @level = level @view_level = LEVEL_MAPPING[level] end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
11 12 13 |
# File 'lib/toolsmith/views/flash_div.rb', line 11 def level @level end |
#view_level ⇒ Object (readonly)
Returns the value of attribute view_level.
12 13 14 |
# File 'lib/toolsmith/views/flash_div.rb', line 12 def view_level @view_level end |
Instance Method Details
#close_link ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/toolsmith/views/flash_div.rb', line 28 def close_link context.link_to( close_link_text, "#", class: "close", data: { dismiss: "alert" } ) end |
#close_link_text ⇒ Object
47 48 49 |
# File 'lib/toolsmith/views/flash_div.rb', line 47 def close_link_text context.raw("×") end |
#container ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/toolsmith/views/flash_div.rb', line 39 def container context.full_width_column do content_tag :div, class: "alert alert-#{view_level}" do yield end end end |
#to_s ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/toolsmith/views/flash_div.rb', line 20 def to_s if context.flash[level].present? container do close_link + context.flash[level].html_safe end end end |