class DynamicScaffold::Form::Item::CarrierWaveImage

Attributes

options[R]

Public Class Methods

new(config, type, name, options = {}) click to toggle source
Calls superclass method DynamicScaffold::Form::Item::Base::new
# File lib/dynamic_scaffold/form/item/carrier_wave_image.rb, line 6
def initialize(config, type, name, options = {})
  super(config, type, name, {})
  @options = options
  @options[:removable] = true if @options[:removable].nil?
end

Public Instance Methods

cropper() click to toggle source
# File lib/dynamic_scaffold/form/item/carrier_wave_image.rb, line 12
def cropper
  return nil unless @options.key? :cropper
  return {} if @options[:cropper] == true

  @options[:cropper]
end
extract_parameters(permitting) click to toggle source
# File lib/dynamic_scaffold/form/item/carrier_wave_image.rb, line 34
def extract_parameters(permitting)
  # If you do not permit before the image body you can not use cropper value in uploader.
  permitting << "cropper_#{@name}" unless cropper.nil?
  permitting << "remove_#{@name}" if @options[:removable]
  permitting.concat(["#{@name}_cache", @name])
end
preview_image_style() click to toggle source
# File lib/dynamic_scaffold/form/item/carrier_wave_image.rb, line 19
def preview_image_style
  max_size = @options[:preview_max_size]
  return '' unless max_size

  ' '.tap do |s|
    s << "max-width: #{max_size[:width]};" if max_size[:width]
    s << "max-height: #{max_size[:height]};" if max_size[:height]
  end
end
render(_view, _form, classnames = nil) { |html_attributes| ... } click to toggle source
# File lib/dynamic_scaffold/form/item/carrier_wave_image.rb, line 29
def render(_view, _form, classnames = nil)
  html_attributes = build_html_attributes(classnames)
  yield(html_attributes)
end