Skip to content

Commit

Permalink
Revert "added support for am-validations"
Browse files Browse the repository at this point in the history
This reverts commit d26e9c3.
  • Loading branch information
Markus Schirp committed Jul 19, 2010
1 parent d26e9c3 commit 01f70f0
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 133 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -5,7 +5,7 @@ require 'rake/gempackagetask'

$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'dm-core'
#require 'dm-validations'
require 'dm-validations'
require 'dm-paperclip'

desc 'Default: run unit tests.'
Expand Down
20 changes: 2 additions & 18 deletions lib/dm-paperclip.rb
Expand Up @@ -81,7 +81,6 @@ class Configuration

attr_writer :root, :env
attr_accessor :use_dm_validations
attr_accessor :use_am_validations

def root
@root ||= Dir.pwd
Expand Down Expand Up @@ -225,19 +224,9 @@ def self.attachment_definitions=(obj)

# Done at this time to ensure that the user
# had a chance to configure the app in an initializer
raise if Paperclip.config.use_dm_validations && Paperclip.config.use_am_validations

if Paperclip.config.use_dm_validations
require 'dm-active_model'
require 'dm-paperclip/am-validations'
base.extend Paperclip::Validate::ClassMethods
end

if Paperclip.config.use_am_validations
require 'active_model'
require 'dm-active_model'
require 'dm-paperclip/am-validations'
base.send(:include,ActiveModel::Validations)
require 'dm-validations'
require 'dm-paperclip/validations'
base.extend Paperclip::Validate::ClassMethods
end

Expand Down Expand Up @@ -340,11 +329,6 @@ def has_attached_file name, options = {}
add_validator_to_context(opts_from_validator_args([name]), [name], Paperclip::Validate::CopyAttachmentErrors)
end

if Paperclip.config.use_am_validations
#add_validator_to_context(opts_from_validator_args([name]), [name], Paperclip::Validate::CopyAttachmentErrors)
validates_with Paperclip::Validate::CopyAttachmentErrors, _merge_attributes([name])
end

end

# Returns the attachment definitions defined by each call to
Expand Down
110 changes: 0 additions & 110 deletions lib/dm-paperclip/am-validations.rb

This file was deleted.

File renamed without changes.
7 changes: 3 additions & 4 deletions test/helper.rb
Expand Up @@ -5,7 +5,7 @@
require 'tempfile'

require 'dm-core'
#require 'dm-validations'
require 'dm-validations'
require 'dm-migrations'
begin
require 'ruby-debug'
Expand Down Expand Up @@ -46,16 +46,15 @@ class Mash < Hash
Paperclip.configure do |config|
config.root = Merb.root # the application root to anchor relative urls (defaults to Dir.pwd)
config.env = Merb.env # server env support, defaults to ENV['RACK_ENV'] or 'development'
#config.use_dm_validations = true # validate attachment sizes and such, defaults to false
config.use_am_validations = true # validate attachment sizes and such, defaults to false
config.use_dm_validations = true # validate attachment sizes and such, defaults to false
end

def rebuild_model options = {}
Object.send(:remove_const, "Dummy") rescue nil
Object.const_set("Dummy", Class.new())
Dummy.class_eval do
include DataMapper::Resource
#include DataMapper::Validate
include DataMapper::Validate
include Paperclip::Resource
property :id, ::DataMapper::Types::Serial
property :other, String
Expand Down
1 change: 1 addition & 0 deletions test/paperclip_test.rb
Expand Up @@ -19,6 +19,7 @@ class PaperclipTest < Test::Unit::TestCase
Object.const_set("DummyTwo", Class.new())
DummyTwo.class_eval do
include DataMapper::Resource
include DataMapper::Validate
include Paperclip::Resource
property :id, DataMapper::Types::Serial
property :other, String
Expand Down

0 comments on commit 01f70f0

Please sign in to comment.