lib/dynamic_image/model.rb in dynamic_image-2.0.2 vs lib/dynamic_image/model.rb in dynamic_image-2.0.3
- old
+ new
@@ -1,9 +1,10 @@
# encoding: utf-8
-require 'dynamic_image/model/dimensions'
-require 'dynamic_image/model/validations'
+require "dynamic_image/model/dimensions"
+require "dynamic_image/model/transformations"
+require "dynamic_image/model/validations"
module DynamicImage
# = DynamicImage Model
#
# ActiveModel extension for the model holding image data. It assumes your
@@ -60,44 +61,45 @@
# image, and as close to the center as possible without zooming in.
module Model
extend ActiveSupport::Concern
include Dis::Model
include DynamicImage::Model::Dimensions
+ include DynamicImage::Model::Transformations
include DynamicImage::Model::Validations
included do
before_validation :read_image_metadata, if: :data_changed?
end
# Returns true if the image is in the CMYK colorspace
def cmyk?
- colorspace == 'cmyk'
+ colorspace == "cmyk"
end
# Returns true if the image is in the grayscale colorspace
def gray?
- colorspace == 'gray'
+ colorspace == "gray"
end
# Returns true if the image is in the RGB colorspace
def rgb?
- colorspace == 'rgb'
+ colorspace == "rgb"
end
# Finds a web safe content type. GIF, JPEG and PNG images are allowed,
# any other formats should be converted to JPEG.
def safe_content_type
if safe_content_types.include?(content_type)
content_type
else
- 'image/jpeg'
+ "image/jpeg"
end
end
# Includes a timestamp fingerprint in the URL param, so
# that rendered images can be cached indefinitely.
def to_param
- [id, updated_at.utc.to_s(cache_timestamp_format)].join('-')
+ [id, updated_at.utc.to_s(cache_timestamp_format)].join("-")
end
private
def read_image_metadata