class Array

Public Instance Methods

extract_options!() click to toggle source

Public: Removes and returns the last element of the Array if it is a Hash.

Examples

array = ["one", "two", {three: 'four'}]
opts  = array.extract_options!
# => {three: 'four'}
array
# => ["one", "two"]

Returns the last element of the Array if it is a Hash, otherwise an empty hash is returned.

# File lib/confer/extensions/array.rb, line 17
def extract_options!
  return pop if last.is_a?(Hash)
  {}
end