Sha256: 71d5cc50113f19eef4900658c4f097fb91ac94cdc7fd3664b71d0b0c586fb2c6

Contents?: true

Size: 418 Bytes

Versions: 1

Compression:

Stored size: 418 Bytes

Contents

# Array extensions
class Array
  # Removes and returns the last member of the array if it is a hash. Otherwise,
  # an empty hash is returned This method is useful when writing methods that
  # take an options hash as the last parameter. For example:
  #
  #   def validate_each(*args, &block)
  #     opts = args.extract_options!
  #     ...
  #   end
  def extract_options!
    last.is_a?(Hash) ? pop : {}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rcap-2.4.0 lib/assistance/extract_options.rb