def register_dragonfly_app(macro_name, app)
(class << self; self; end).class_eval do
define_method macro_name do |attribute|
before_save :save_dragonfly_attachments unless respond_to?(:before_save_callback_chain) && before_save_callback_chain.find(:save_dragonfly_attachments)
before_destroy :destroy_dragonfly_attachments unless respond_to?(:before_destroy_callback_chain) && before_destroy_callback_chain.find(:destroy_dragonfly_attachments)
dragonfly_apps_for_attributes[attribute] = app
define_method "#{attribute}=" do |value|
dragonfly_attachments[attribute].assign(value)
end
define_method attribute do
dragonfly_attachments[attribute].to_value
end
end
end
app
end