Sha256: 1a25f66e42f298d498d10674d788c552d06ee92771c2561f678b9535fd4bf4a0

Contents?: true

Size: 363 Bytes

Versions: 2

Compression:

Stored size: 363 Bytes

Contents

module Id
  module Model
    class HasOne < Association

      def value_of(data)
        if optional?
          child = data.fetch(key, nil)
          child.nil? ? None : Some[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

2 entries across 2 versions & 1 rubygems

Version Path
id-0.0.12 lib/id/model/has_one.rb
id-0.0.11 lib/id/model/has_one.rb