Sha256: 646b5cb22d7ddfdf6ae7590cc1d7d6d462e4a727564f87b52f7ad9a4904960bc
Contents?: true
Size: 594 Bytes
Versions: 2
Compression:
Stored size: 594 Bytes
Contents
module HasUuid module ActiveRecord module Associations module SingularAssociation extend ActiveSupport::Concern included do def uuid_writer(uuid) replace(klass.find(uuid)) unless uuid.nil? || uuid.to_s.empty? replace(nil) if uuid.nil? || uuid.to_s.empty? end def uuid_reader(force_reload = false) id = self.owner.send(reflection.foreign_key) if id klass.find(id).uuid else nil end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_has_uuid-0.3.0 | lib/has_uuid/active_record/associations/singular_association.rb |
rails_has_uuid-0.2.0 | lib/has_uuid/active_record/associations/singular_association.rb |