Sha256: 733379482fc5d74ba9105cb045dea69c50d5d08b88053fd42c0ec9c3ae94a87e

Contents?: true

Size: 388 Bytes

Versions: 2

Compression:

Stored size: 388 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 & 2 rubygems

Version Path
chrislloyd-coinage-0.2.0 lib/coinage/core_ext/array.rb
coinage-0.2.0 lib/coinage/core_ext/array.rb