From 8feee320f33e2798963237771465ea1f035e9a39 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 26 Mar 2009 21:07:22 -0700 Subject: [PATCH] Move Model.extract_options! from base to the validation_class_method plugin, since that is the only user --- lib/sequel/model/base.rb | 7 ------- lib/sequel/model/deprecated_validations.rb | 4 ++++ lib/sequel/plugins/validation_class_methods.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/sequel/model/base.rb b/lib/sequel/model/base.rb index 71a725f9e1..b20fcda1a2 100644 --- a/lib/sequel/model/base.rb +++ b/lib/sequel/model/base.rb @@ -350,13 +350,6 @@ def def_bad_column_accessor(column) end end - # Removes and returns the last member of the array if it is a hash. Otherwise, - # an empty hash is returned This method is useful when writing methods that - # take an options hash as the last parameter. - def extract_options!(array) - array.last.is_a?(Hash) ? array.pop : {} - end - # Get the schema from the database, fall back on checking the columns # via the database if that will return inaccurate results or if # it raises an error. diff --git a/lib/sequel/model/deprecated_validations.rb b/lib/sequel/model/deprecated_validations.rb index 80353d54c0..b07317c8f6 100644 --- a/lib/sequel/model/deprecated_validations.rb +++ b/lib/sequel/model/deprecated_validations.rb @@ -361,6 +361,10 @@ def validations private + def extract_options!(array) + array.last.is_a?(Hash) ? array.pop : {} + end + def validation_if_proc(o, i) case i when Symbol then o.send(i) diff --git a/lib/sequel/plugins/validation_class_methods.rb b/lib/sequel/plugins/validation_class_methods.rb index 3ff6c8f848..8b38ca38be 100644 --- a/lib/sequel/plugins/validation_class_methods.rb +++ b/lib/sequel/plugins/validation_class_methods.rb @@ -352,6 +352,14 @@ def validations private + # Removes and returns the last member of the array if it is a hash. Otherwise, + # an empty hash is returned This method is useful when writing methods that + # take an options hash as the last parameter. + def extract_options!(array) + array.last.is_a?(Hash) ? array.pop : {} + end + + # Handle the :if option for validations def validation_if_proc(o, i) case i when Symbol then o.send(i)