Sha256: f78f43e395b0bc0e2a9c9dc64a056662100c29a9c8b8ed809ab13927b9a342ae

Contents?: true

Size: 366 Bytes

Versions: 3

Compression:

Stored size: 366 Bytes

Contents

class Array
  def merge_options(update_hash={})
    endex, base_hash = options_extractable? ? [ -2, last ] : [ -1, {} ]
    Array[ *self[0..endex], base_hash.merge(update_hash || {}) ]
  end
  alias_method :merge_opts, :merge_options

  def merge_options!(update_hash={})
    push(extract_options!(update_hash))
  end
  alias_method :merge_opts!, :merge_options!
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
core_utilities-0.1.3 lib/core_utilities/core_ext/array/merge_options.rb
core_utilities-0.1.1 lib/core_utilities/core_ext/array/merge_options.rb
core_utilities-0.1.0 lib/core_utilities/core_ext/array/merge_options.rb