Sha256: 98e232ee653b028ec1c0a46e7c1c727adf129131c6f34d5cf6aa40f2c276b83b

Contents?: true

Size: 382 Bytes

Versions: 2

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

2 entries across 2 versions & 1 rubygems

Version Path
ironnails-0.0.3 lib/ironnails/core_ext/array.rb
ironnails-0.0.1 lib/ironnails/core_ext/array.rb