Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp add in of active supports experimental callbacks ... until Rails…
… 3 is out
- Loading branch information
1 parent
f538e3a
commit b30561c
Showing
6 changed files
with
958 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Array | ||
# Wraps the object in an Array unless it's an Array. Converts the | ||
# object to an Array using #to_ary if it implements that. | ||
def self.wrap(object) | ||
if object.nil? | ||
[] | ||
elsif object.respond_to?(:to_ary) | ||
object.to_ary | ||
else | ||
[object] | ||
end | ||
end | ||
|
||
# Extracts options from a set of arguments. Removes and returns the last | ||
# element in the array if it's a hash, otherwise returns a blank hash. | ||
# | ||
# def options(*args) | ||
# args.extract_options! | ||
# end | ||
# | ||
# options(1, 2) # => {} | ||
# options(1, 2, :a => :b) # => {:a=>:b} | ||
def extract_options! | ||
last.is_a?(::Hash) ? pop : {} | ||
end | ||
|
||
end |
Oops, something went wrong.