Sha256: bd64ab29d51af1dec5b1850adf6ef627648d0bf98ee86ed28132af35fc92a091

Contents?: true

Size: 297 Bytes

Versions: 3

Compression:

Stored size: 297 Bytes

Contents

module Dry
  module Data
    class Optional
      attr_reader :type

      def initialize(type)
        @type = type
      end

      def valid?(input)
        type.valid?(input)
      end

      def call(input)
        Maybe(type[input])
      end
      alias_method :[], :call
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-data-0.4.2 lib/dry/data/optional.rb
dry-data-0.4.1 lib/dry/data/optional.rb
dry-data-0.4.0 lib/dry/data/optional.rb