Sha256: 8683edd0713a3c56366029bf0f20e46e6f4ade0a5cf49db14e0a8734a4fe72c4

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 Bytes

Contents

module Option
  module Enumerable
    include ::Enumerable

    def map
      from_array super
    end
    alias_method :collect, :map
    alias_method :flat_map, :map
    alias_method :collect_concat, :map

    def detect
      from_value super
    end
    alias_method :find, :detect

    def select
      from_array super
    end
    alias_method :find_all, :select

    def grep(value)
      from_array super
    end

    def reject
      from_array super
    end

    def reduce(*args, &block)
      if none? && (args.size < 1 || args.size < 2 && block.nil?)
        raise ValueOfNoneError
      end
      super
    end
    alias_method :inject, :reduce
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
optional-0.0.2 lib/optional/option/enumerable.rb
optional-0.0.1 lib/optional/option/enumerable.rb