Sha256: 75e3a085ebd3bc86b544fc783e5a9375b9fb16962e74eac1793ef0aaa78ad2fe
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
module Ckeditor module Backend module Paperclip def self.included(base) base.send(:include, InstanceMethods) base.send(:extend, ClassMethods) end module ClassMethods def self.extended(base) base.class_eval do # before_validation :extract_content_type before_create :read_dimensions, :parameterize_filename delegate :url, :path, :styles, :size, :content_type, :to => :data end end end module InstanceMethods def geometry @geometry ||= ::Paperclip::Geometry.from_file(file) end protected def file @file ||= data.respond_to?(:queued_for_write) ? data.queued_for_write[:original] : data.to_file end def parameterize_filename unless data_file_name.blank? filename = Ckeditor::Utils.parameterize_filename(data_file_name) self.data.instance_write(:file_name, filename) end end def read_dimensions if image? && has_dimensions? self.width = geometry.width self.height = geometry.height end end def extract_content_type path = file.nil? ? nil : file.path self.data_content_type = Utils::ContentTypeDetector.new(path).detect end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
glebtv-ckeditor-4.6.0 | lib/ckeditor/backend/paperclip.rb |
glebtv-ckeditor-4.5.10.3 | lib/ckeditor/backend/paperclip.rb |
glebtv-ckeditor-4.5.10.2 | lib/ckeditor/backend/paperclip.rb |