Class: Paperclip::Validate::GeometryValidator
- Inherits:
-
DataMapper::Validate::GenericValidator
- Object
- DataMapper::Validate::GenericValidator
- Paperclip::Validate::GeometryValidator
- Defined in:
- lib/dm-paperclip/validations.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#call(target) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/dm-paperclip/validations.rb', line 109 def call(target) field_value = target.validation_property_value(@field_name) return true if field_value.queued_for_write[:original].nil? geometry = Paperclip::Geometry.from_file(field_value.queued_for_write[:original].path) return true if @options[:width].include?(geometry.width) && @options[:height].include?(geometry.height) ||= sprintf("%s width must be between %s and %s px", DataMapper::Inflector.humanize(@field_name), @options[:width].begin, @options[:width].end) unless @options[:width].include?(geometry.width) ||= sprintf("%s height must be between %s and %s px", DataMapper::Inflector.humanize(@field_name), @options[:height].begin, @options[:height].end) unless@options[:height].include?(geometry.height) add_error(target, , @field_name) return false end |