Sha256: 0f2f6f8bd3189bf022cb2f6416e953af6f66120a459303bd971758782a4f904a

Contents?: true

Size: 375 Bytes

Versions: 1

Compression:

Stored size: 375 Bytes

Contents

module Id
  module Model
    class HasOne < Association

      def value_of(data)
        if optional?
          child = data.fetch(field.key, nil)
          child.nil? ? None : Some[field.type.new(child)]
        else
          child = data.fetch(key) { raise MissingAttributeError, key }
          type.new(child) unless child.nil?
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
id-0.0.10 lib/id/model/has_one.rb