Skip to content

Commit

Permalink
Move Model.extract_options! from base to the validation_class_method …
Browse files Browse the repository at this point in the history
…plugin, since that is the only user
  • Loading branch information
jeremyevans committed Mar 27, 2009
1 parent 9b429cc commit 8feee32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/sequel/model/base.rb
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions lib/sequel/model/deprecated_validations.rb
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions lib/sequel/plugins/validation_class_methods.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 8feee32

Please sign in to comment.