lib/adminos/helpers/models/cropped.rb in adminos-1.0.0.pre.rc.1 vs lib/adminos/helpers/models/cropped.rb in adminos-1.0.0.pre.rc.2

- old
+ new

@@ -1,20 +1,24 @@ module Adminos::Cropped extend ActiveSupport::Concern module ClassMethods - def cropped(as_attribute, coord_attribute = nil) + def cropped(as_attribute, *args) + options = args.extract_options! - define_method "#{as_attribute}_cropped" do - public_send(as_attribute).variant(combine_options: { crop: public_send("#{as_attribute}_cropped_coord") }) + version = options.delete(:version) || :default + coord_attribute = options.delete(:coord_attribute) || "#{as_attribute}_coord" + + define_method "#{version}_#{as_attribute}_cropped" do + public_send(as_attribute).variant(combine_options: { crop: public_send("#{version}_#{as_attribute}_coord") }) end - define_method "#{as_attribute}_attr_coord" do - coord_attribute || "#{as_attribute}_coord" + define_method "#{version}_#{as_attribute}_attr_coord" do + coord_attribute end - define_method "#{as_attribute}_cropped_coord" do - public_send(public_send("#{as_attribute}_attr_coord")) + define_method "#{version}_#{as_attribute}_coord" do + public_send(public_send("#{version}_#{as_attribute}_attr_coord")) end end end end