Sha256: 26cc50632d37b84ed7520bb4cfd5fc79dc069502a8bb44e1d7e2b4309cad348d

Contents?: true

Size: 403 Bytes

Versions: 3

Compression:

Stored size: 403 Bytes

Contents

# from ActiveSupport
class Array
  # 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

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
rets4r-1.1.18 lib/rets4r/core_ext/array/extract_options.rb
jschairb-rets4r-1.1.18 lib/rets4r/core_ext/array/extract_options.rb
josephholsten-rets4r-1.1.17 lib/rets4r/core_ext/array/extract_options.rb