Skip to content

Commit

Permalink
temp add in of active supports experimental callbacks ... until Rails…
Browse files Browse the repository at this point in the history
… 3 is out
  • Loading branch information
baccigalupi committed Nov 23, 2009
1 parent f538e3a commit b30561c
Show file tree
Hide file tree
Showing 6 changed files with 958 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/aqua/support/active_support/array.rb
@@ -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

0 comments on commit b30561c

Please sign in to comment.