Class: Cloudpress::Renderers::Flash
- Inherits:
-
Object
- Object
- Cloudpress::Renderers::Flash
- Defined in:
- lib/cloudpress/renderers/flash.rb
Instance Attribute Summary collapse
- #content ⇒ Object
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #content? ⇒ Boolean
- #flash_html_attributes ⇒ Object
- #icon ⇒ Object
-
#initialize(context, type, options = {}) ⇒ Flash
constructor
A new instance of Flash.
- #render ⇒ Object
Constructor Details
#initialize(context, type, options = {}) ⇒ Flash
Returns a new instance of Flash.
7 8 9 10 11 |
# File 'lib/cloudpress/renderers/flash.rb', line 7 def initialize(context, type, ={}) @context = context @type = type @options = .reverse_merge() end |
Instance Attribute Details
#content ⇒ Object
13 14 15 |
# File 'lib/cloudpress/renderers/flash.rb', line 13 def content @content ? @content : @context.content_tag(:p, @context.flash[type]) end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/cloudpress/renderers/flash.rb', line 5 def @options end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/cloudpress/renderers/flash.rb', line 5 def type @type end |
Instance Method Details
#content? ⇒ Boolean
17 18 19 |
# File 'lib/cloudpress/renderers/flash.rb', line 17 def content? !!content end |
#flash_html_attributes ⇒ Object
32 33 34 35 36 37 |
# File 'lib/cloudpress/renderers/flash.rb', line 32 def flash_html_attributes { id: [:id], class: css_classes }.reject { |k, v| v.blank? } end |
#icon ⇒ Object
21 22 23 |
# File 'lib/cloudpress/renderers/flash.rb', line 21 def icon @context.icon([:icon]) if icon? end |
#render ⇒ Object
25 26 27 28 29 30 |
# File 'lib/cloudpress/renderers/flash.rb', line 25 def render return nil unless content? @context.render(layout: 'cloudpress/flashes/flash', locals: {renderer: self}) do content end end |