Class: DynamicScaffold::Form::Item::CarrierWaveImage
- Inherits:
-
Base
- Object
- Base
- DynamicScaffold::Form::Item::CarrierWaveImage
show all
- Defined in:
- lib/dynamic_scaffold/form/item/carrier_wave_image.rb
Constant Summary
Constants inherited
from Base
Base::ITEM_TYPES
Instance Attribute Summary collapse
Attributes inherited from Base
#name
Instance Method Summary
collapse
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?, #unless
Constructor Details
#initialize(config, type, name, options = {}) ⇒ CarrierWaveImage
Returns a new instance of CarrierWaveImage.
6
7
8
9
10
|
# 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
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
5
6
7
|
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 5
def options
@options
end
|
Instance Method Details
#cropper ⇒ Object
12
13
14
15
16
17
|
# 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
|
34
35
36
37
38
39
|
# File 'lib/dynamic_scaffold/form/item/carrier_wave_image.rb', line 34
def (permitting)
permitting << "cropper_#{@name}" unless cropper.nil?
permitting << "remove_#{@name}" if @options[:removable]
permitting.concat(["#{@name}_cache", @name])
end
|
#preview_image_style ⇒ Object
19
20
21
22
23
24
25
26
27
|
# 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| ... } ⇒ Object
29
30
31
32
|
# 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
|