Sha256: f6fd3773a3f36c39ef899480ee45d1aef6fc7bc094bc7eaffda9400b81d15503

Contents?: true

Size: 566 Bytes

Versions: 3

Compression:

Stored size: 566 Bytes

Contents

class Array
  def extract_options
    options_extractable? ? last : {}
  end
  
  def extract_options!
    options_extractable? ? pop  : {}
  end
  
  def options_extractable?
    last.is_a?(Hash) && last.extractable_options?
  end
  
  def extract_options_with_merge(update_hash={})
    extract_options_without_merge.merge(update_hash  || {})
  end
  alias_method_chain :extract_options,  :merge
  
  def extract_options_with_merge!(update_hash={})
    extract_options_without_merge!.merge(update_hash || {})
  end
  alias_method_chain :extract_options!, :merge
end

Version data entries

3 entries across 3 versions & 1 rubygems

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