module PaperCropper::Schema::TableDefinition

Public Instance Methods

crop_attachment(*attachment_names) click to toggle source
# 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