Module: CarrierWave::Elastictastic

Includes:
Mount
Defined in:
lib/carrierwave/orm/elastictastic.rb,
lib/carrierwave/orm/elastictastic/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#mount_uploader(column, uploader = nil, options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/carrierwave/orm/elastictastic.rb', line 8

def mount_uploader(column, uploader=nil, options={}, &block)
  field options[:mount_on] || column

  super

  alias_method :read_uploader, :read_attribute
  alias_method :write_uploader, :write_attribute

  public :read_uploader
  public :write_uploader

  include CarrierWave::Validations::ActiveModel

  validates_integrity_of  column if uploader_option column.to_sym, :validate_integrity
  validates_processing_of column if uploader_option column.to_sym, :validate_processing

  after_save :"store_#{column}!"
  before_save :"write_#{column}_identifier"
  after_destroy :"remove_#{column}!"
end