Class: Alchemy::EssencePictureView
- Inherits:
-
Object
- Object
- Alchemy::EssencePictureView
- Includes:
- ActionView::Helpers::AssetTagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- app/models/alchemy/essence_picture_view.rb
Overview
Renders an essence picture view
Constant Summary collapse
- DEFAULT_OPTIONS =
{ show_caption: true, disable_link: false }
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#essence ⇒ Object
readonly
Returns the value of attribute essence.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#picture ⇒ Object
readonly
Returns the value of attribute picture.
Instance Method Summary collapse
-
#initialize(content, options = {}, html_options = {}) ⇒ EssencePictureView
constructor
A new instance of EssencePictureView.
- #render ⇒ Object
Constructor Details
#initialize(content, options = {}, html_options = {}) ⇒ EssencePictureView
Returns a new instance of EssencePictureView.
15 16 17 18 19 20 21 |
# File 'app/models/alchemy/essence_picture_view.rb', line 15 def initialize(content, = {}, = {}) @content = content @options = DEFAULT_OPTIONS.update(content.settings).update() @html_options = @essence = content.essence @picture = essence.picture end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'app/models/alchemy/essence_picture_view.rb', line 8 def content @content end |
#essence ⇒ Object (readonly)
Returns the value of attribute essence.
8 9 10 |
# File 'app/models/alchemy/essence_picture_view.rb', line 8 def essence @essence end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
8 9 10 |
# File 'app/models/alchemy/essence_picture_view.rb', line 8 def @html_options end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'app/models/alchemy/essence_picture_view.rb', line 8 def @options end |
#picture ⇒ Object (readonly)
Returns the value of attribute picture.
8 9 10 |
# File 'app/models/alchemy/essence_picture_view.rb', line 8 def picture @picture end |
Instance Method Details
#render ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/alchemy/essence_picture_view.rb', line 23 def render return if picture.blank? output = ? img_tag + : img_tag if is_linked? output = link_to(output, url_for(essence.link), { title: essence.link_title.presence, target: essence.link_target == "blank" ? "_blank" : nil, data: {link_target: essence.link_target.presence} }) end if content_tag(:figure, output, {class: essence.css_class.presence}.merge()) else output end end |