Sha256: 4b929c7c6a4e07a192b178c3cc1d6f78e5a582440ee4858a74321911c1e2cd1b
Contents?: true
Size: 680 Bytes
Versions: 3
Compression:
Stored size: 680 Bytes
Contents
module Id module Model class HasOne < Association def define_getter field = self model.send :define_method, name do memoize field.name do child = data.fetch(field.key) { raise MissingAttributeError, field.key } field.type.new(child) unless child.nil? end end end end class HasOneOption < Association def define_getter field = self model.send :define_method, name do memoize field.name do child = data.fetch(field.key, nil) child.nil? ? None : Some[field.type.new(child)] end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
id-0.0.9 | lib/id/model/has_one.rb |
id-0.0.8 | lib/id/model/has_one.rb |
id-0.0.7 | lib/id/model/has_one.rb |