Class: PhrasingImageWidget

Inherits:
SimpleDelegator
  • Object
show all
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

Instance Method Summary collapse

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, options = {})
  super(phrasing_image)
  @view_context = view_context
  @options = 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_imageObject

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

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'app/widgets/phrasing_image_widget.rb', line 8

def options
  @options
end

#wrapper_optionsObject

Returns the value of attribute wrapper_options.



8
9
10
# File 'app/widgets/phrasing_image_widget.rb', line 8

def wrapper_options
  @wrapper_options
end

Instance Method Details

#image_urlObject



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(options).url
end