Sha256: 279b1a41c47dc328930fc3514deb4e052b07cdf253cbc15f8bbf0cbd45b64e4c

Contents?: true

Size: 359 Bytes

Versions: 18

Compression:

Stored size: 359 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

18 entries across 18 versions & 2 rubygems

Version Path
grippy-doozer-0.1.0 lib/doozer/active_support/array.rb
grippy-doozer-0.1.1 lib/doozer/active_support/array.rb
grippy-doozer-0.1.2 lib/doozer/active_support/array.rb
grippy-doozer-0.1.3 lib/doozer/active_support/array.rb
grippy-doozer-0.1.4 lib/doozer/active_support/array.rb
grippy-doozer-0.1.5 lib/doozer/active_support/array.rb
doozer-0.4.4 lib/doozer/active_support/array.rb
doozer-0.4.3 lib/doozer/active_support/array.rb
doozer-0.4.2 lib/doozer/active_support/array.rb
doozer-0.4.1 lib/doozer/active_support/array.rb
doozer-0.4.0 lib/doozer/active_support/array.rb
doozer-0.3.1 lib/doozer/active_support/array.rb
doozer-0.3.0 lib/doozer/active_support/array.rb
doozer-0.2.6 lib/doozer/active_support/array.rb
doozer-0.2.5 lib/doozer/active_support/array.rb
doozer-0.2.2 lib/doozer/active_support/array.rb
doozer-0.2.1 lib/doozer/active_support/array.rb
doozer-0.2.0 lib/doozer/active_support/array.rb