Sha256: ffcdcce91e05fb03b42c622cf66f675a1d635d1760bbf0cd8cf99a9870f19e4d

Contents?: true

Size: 382 Bytes

Versions: 11

Compression:

Stored size: 382 Bytes

Contents

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

11 entries across 11 versions & 4 rubygems

Version Path
activesupport-3.0.0.beta lib/active_support/core_ext/array/extract_options.rb
couch_tomato-0.2.0 lib/core_ext/extract_options.rb
a_b_plugin-0.1.0 lib/a_b_plugin/core_ext/array.rb
couch_tomato-0.1.5 lib/core_ext/extract_options.rb
couch_tomato-0.1.4 lib/core_ext/extract_options.rb
couch_tomato-0.1.3 lib/core_ext/extract_options.rb
couch_tomato-0.1.2 lib/core_ext/extract_options.rb
couch_tomato-0.1.1 lib/core_ext/extract_options.rb
couch_tomato-0.1.0 lib/core_ext/extract_options.rb
activesupport-3.0.pre lib/active_support/core_ext/array/extract_options.rb
recliner-0.0.1 vendor/activesupport/lib/active_support/core_ext/array/extract_options.rb