Upgraded Rails and RSpec
[monkeycharger.git] / vendor / rails / activesupport / lib / active_support / core_ext / array / extract_options.rb
blob980d36400b9976c9de475fa068f8050fb02a0520
1 module ActiveSupport #:nodoc:
2   module CoreExtensions #:nodoc:
3     module Array #:nodoc:
4       module ExtractOptions
5         # Extract 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.
6         #
7         #   def options(*args)
8         #     args.extract_options!
9         #   end
10         #
11         #   options(1, 2)           # => {}
12         #   options(1, 2, :a => :b) # => {:a=>:b}
13         def extract_options!
14           last.is_a?(::Hash) ? pop : {}
15         end
16       end
17     end
18   end
19 end