Module: PaperCropper::Schema::TableDefinition

Defined in:
lib/paper_cropper/schema.rb

Overview

#########################################################################

Instance Method Summary collapse

Instance Method Details

#crop_attachment(*attachment_names) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/paper_cropper/schema.rb', line 45

def crop_attachment(*attachment_names)
  options = attachment_names.extract_options!
  attachment_names.each do |attachment_name|
    COLUMNS.each_pair do |column_name, column_definition|
      column_type, default_options = column_definition
      custom_options = options.merge(options[column_name.to_sym] || {})
      column_options = (default_options || {}).merge(custom_options)
      column("#{attachment_name}_#{column_name}", column_type, column_options)
    end
  end
end