Class: Toolsmith::Views::FlashDiv
- Defined in:
- lib/toolsmith/views/flash_div.rb
Constant Summary collapse
- LEVEL_MAPPING =
{ error: :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.
13 14 15 16 17 |
# File 'lib/toolsmith/views/flash_div.rb', line 13 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.
10 11 12 |
# File 'lib/toolsmith/views/flash_div.rb', line 10 def level @level end |
#view_level ⇒ Object (readonly)
Returns the value of attribute view_level.
11 12 13 |
# File 'lib/toolsmith/views/flash_div.rb', line 11 def view_level @view_level end |
Instance Method Details
#close_link ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/toolsmith/views/flash_div.rb', line 27 def close_link context.link_to( close_link_text, "#", class: "close", data: { dismiss: "alert" } ) end |
#close_link_text ⇒ Object
46 47 48 |
# File 'lib/toolsmith/views/flash_div.rb', line 46 def close_link_text context.raw("×") end |
#container ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/toolsmith/views/flash_div.rb', line 38 def container context.full_width_column do content_tag :div, class: "alert alert-#{view_level}" do yield end end end |
#to_s ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/toolsmith/views/flash_div.rb', line 19 def to_s if context.flash[level].present? container do close_link + context.flash[level].html_safe end end end |