Sha256: f68eb325c785d9bf1e4f8bb1ef4931fbd6493ff7a60ca54db967245bae8a260b

Contents?: true

Size: 538 Bytes

Versions: 2

Compression:

Stored size: 538 Bytes

Contents

class Array
  def deep_merge_hashes
    self.inject({}) do |res, h|
      raise Exception.new("Not a hash #{h}") unless h.is_a?(Hash)
      h.deep_merge(res)
    end
  end

  def mean
    return 0 if size == 0
    inject(:+) / size
  end

  def without!(*values)
    ActiveSupport::Deprecation.warn('Array#without! is deprecated without replacement')
    values.flatten.each { |value| self.delete(value) }
    self
  end

  def contain?(other)
    (other - self).empty?
  end

  def intersect?(other)
    !(self & other).empty?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ab_admin-0.11.0 lib/ab_admin/core_ext/array.rb
ab_admin-0.10.0 lib/ab_admin/core_ext/array.rb