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, srcset: [], sizes: [] }.with_indifferent_access
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.
19 20 21 22 23 24 25 |
# File 'app/models/alchemy/essence_picture_view.rb', line 19 def initialize(content, = {}, = {}) @content = content @options = DEFAULT_OPTIONS.merge(content.settings).merge() @html_options = @essence = content.essence @picture = essence.picture end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'app/models/alchemy/essence_picture_view.rb', line 10 def content @content end |
#essence ⇒ Object (readonly)
Returns the value of attribute essence.
10 11 12 |
# File 'app/models/alchemy/essence_picture_view.rb', line 10 def essence @essence end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
10 11 12 |
# File 'app/models/alchemy/essence_picture_view.rb', line 10 def @html_options end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'app/models/alchemy/essence_picture_view.rb', line 10 def @options end |
#picture ⇒ Object (readonly)
Returns the value of attribute picture.
10 11 12 |
# File 'app/models/alchemy/essence_picture_view.rb', line 10 def picture @picture end |
Instance Method Details
#render ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/alchemy/essence_picture_view.rb', line 27 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 |