Commit f82c0d94 by Daniel Schierbeck

Further refactor the schema implementation

parent f3eacd24
......@@ -12,21 +12,26 @@ module Paperclip
:updated_at => :datetime}
def has_attached_file(attachment_name)
@@columns.each do |name, type|
column_name = full_column_name(attachment_name, name)
column(column_name, type)
with_columns_for(attachment_name) do |column_name, column_type|
column(column_name, column_type)
end
end
def drop_attached_file(table_name, attachment_name)
@@columns.each do |name, type|
column_name = full_column_name(attachment_name, name)
with_columns_for(attachment_name) do |column_name, column_type|
remove_column(table_name, column_name)
end
end
protected
def with_columns_for(attachment_name)
@@columns.each do |suffix, column_type|
column_name = full_column_name(attachment_name, suffix)
yield column_name, column_type
end
end
def full_column_name(attachment_name, column_name)
"#{attachment_name}_#{column_name}".to_sym
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment