Class: DynamicScaffold::Form::Item::CarrierWaveImage
- Defined in:
- lib/dynamic_scaffold/form/item/carrier_wave_image.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Attributes inherited from Base
#multiple, #name, #parent_item
Instance Method Summary collapse
- #cropper ⇒ Object
- #extract_parameters(permitting) ⇒ Object
-
#initialize(config, type, name, options = {}) ⇒ CarrierWaveImage
constructor
A new instance of CarrierWaveImage.
- #preview_image_style ⇒ Object
- #render(_view, _form, classnames = nil) {|html_attributes| ... } ⇒ Object
Methods inherited from Base
create, #default, #default_value, #errors, #if, #insert, #label, #label?, #needs_rendering?, #note, #notes?, #proxy, #proxy_field, #render_label, #render_notes, #type?, #unique_name, #unless
Constructor Details
#initialize(config, type, name, options = {}) ⇒ CarrierWaveImage
Returns a new instance of CarrierWaveImage.
8 9 10 11 12 |
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 8 def initialize(config, type, name, = {}) super(config, type, name, {}) @options = @options[:removable] = true if @options[:removable].nil? end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 7 def @options end |
Instance Method Details
#cropper ⇒ Object
14 15 16 17 18 19 |
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 14 def cropper return nil unless @options.key? :cropper return {} if @options[:cropper] == true @options[:cropper] end |
#extract_parameters(permitting) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 36 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 ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 21 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| ... } ⇒ Object
31 32 33 34 |
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 31 def render(_view, _form, classnames = nil) html_attributes = build_html_attributes(classnames) yield(html_attributes) end |