lib/buddies_avatar/orm/base.rb in buddies_avatar-0.0.1 vs lib/buddies_avatar/orm/base.rb in buddies_avatar-0.0.2
- old
+ new
@@ -2,19 +2,20 @@
module ORM
module Base
extend ActiveSupport::Concern
included do
+ attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
after_update :reprocess_avatar, if: :cropping?
mount_uploader :avatar, AvatarUploader
end
-
+
def cropping?
- raise NotImplementedError
+ !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
end
-
+
def crop_string
- raise NotImplementedError
+ "#{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}"
end
def avatar_geometry
img = MiniMagick::Image.open avatar_upload_path
@geometry = { width: img[:width], height: img[:height] }
\ No newline at end of file