Class: PhrasingImageWidget
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- PhrasingImageWidget
- Defined in:
- app/widgets/phrasing_image_widget.rb
Constant Summary collapse
- HTML_CLASS =
'phrasable-image'
- WRAPPER_HTML_CLASS =
'phrasable-image-wrapper'
Instance Attribute Summary collapse
-
#default_image ⇒ Object
Returns the value of attribute default_image.
-
#options ⇒ Object
Returns the value of attribute options.
-
#wrapper_options ⇒ Object
Returns the value of attribute wrapper_options.
Instance Method Summary collapse
- #image_url ⇒ Object
-
#initialize(phrasing_image, view_context, options = {}) ⇒ PhrasingImageWidget
constructor
A new instance of PhrasingImageWidget.
Constructor Details
#initialize(phrasing_image, view_context, options = {}) ⇒ PhrasingImageWidget
Returns a new instance of PhrasingImageWidget.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/widgets/phrasing_image_widget.rb', line 10 def initialize(phrasing_image, view_context, = {}) super(phrasing_image) @view_context = view_context @options = @default_image = @options.delete(:default_image) @wrapper_options = @options.delete(:wrapper_html) || {} return unless view_context.can_edit_phrases? add_phrasable_image_class add_phrasable_image_wrapper_class end |
Instance Attribute Details
#default_image ⇒ Object
Returns the value of attribute default_image.
8 9 10 |
# File 'app/widgets/phrasing_image_widget.rb', line 8 def default_image @default_image end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'app/widgets/phrasing_image_widget.rb', line 8 def @options end |
#wrapper_options ⇒ Object
Returns the value of attribute wrapper_options.
8 9 10 |
# File 'app/widgets/phrasing_image_widget.rb', line 8 def @wrapper_options end |
Instance Method Details
#image_url ⇒ Object
23 24 25 |
# File 'app/widgets/phrasing_image_widget.rb', line 23 def image_url image.url || default_image && view_context.asset_url(default_image) || PhrasingPlus::DummyImage.new().url end |