Sha256: ce744839084ed3e5e9e2622dac998538f7fa68bf11fb4faf0bf11735f47093e4
Contents?: true
Size: 711 Bytes
Versions: 5
Compression:
Stored size: 711 Bytes
Contents
require 'ripple/associations/proxy' require 'ripple/associations/one' module Ripple module Associations class OneStoredKeyProxy < Proxy include One def replace(value) @reflection.verify_type!(value, owner) if value assign_key(value.key) else assign_key(nil) end @target = value loaded end protected def key @owner.send(key_name) end def assign_key(value) @owner.send("#{key_name}=", value) end def key_name "#{@reflection.name}_key" end def find_target return nil if key.blank? klass.find(key) end end end end
Version data entries
5 entries across 5 versions & 4 rubygems