Sha256: 43e9244727178d60b134393317706eb275985035535fddd51d639f5ec23bb056
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
module RailsGallery module PhotoValidation def validate_gallery_photo photo return "Photo must be a kind of RGallery::Photo, was: #{photo}" unless photo.kind_of?(RGallery::Photo) return 'Photo must have a #path method' unless photo.respond_to? :path return 'Photo must have a #title method' unless photo.respond_to? :title begin photo.filename photo.file_path rescue Exception => e return "filename or file_path could not be resolved for: #{photo}, cause: #{e}" end return "Photo must have a path: #{photo}" if photo.path.blank? return "Photo must have a title: #{photo}" if photo.title.blank? true end def validate_gallery_photo! photo raise ArgumentError, "Photo must be a kind of RGallery::Photo, was: #{photo}" unless photo.kind_of?(RGallery::Photo) raise ArgumentError, 'Photo must have a #path method' unless photo.respond_to? :path raise ArgumentError, 'Photo must have a #title method' unless photo.respond_to? :title begin photo.filename photo.file_path rescue Exception => e raise ::RailsGallery::ConfigurationError, "filename or file_path could not be resolved for: #{photo}, cause: #{e}" end raise ArgumentError, "Photo must have a path: #{photo}" if photo.path.blank? raise ArgumentError, "Photo must have a title: #{photo}" if photo.title.blank? true end end end
Version data entries
4 entries across 4 versions & 1 rubygems