instance method extract_options!

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

extract_options!()

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}
Source
# File activesupport/lib/active_support/core_ext/array/extract_options.rb, line 14
        def extract_options!
          last.is_a?(::Hash) ? pop : {}
        end

Defined in activesupport/lib/active_support/core_ext/array/extract_options.rb line 14 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveSupport::CoreExtensions::Array::ExtractOptions

Type at least 2 characters to search.

↑↓ navigate · open · esc close