# File lib/has_uuid/active_record/reflection.rb, line 8 def primary_uuid_column @primary_uuid_column ||= klass.columns.find { |c| c.name.to_sym == klass.primary_uuid } end
module HasUuid::ActiveRecord::Reflection::AssociationReflection
Public Instance Methods
active_record_primary_uuid()
click to toggle source
# File lib/has_uuid/active_record/reflection.rb, line 16 def active_record_primary_uuid @active_record_primary_uuid ||= options[:primary_uuid] || primary_uuid(active_record) end
association_primary_uuid(klass = nil)
click to toggle source
# File lib/has_uuid/active_record/reflection.rb, line 12 def association_primary_uuid(klass = nil) options[:primary_uuid] || primary_uuid(klass || self.klass) end
foreign_uuid()
click to toggle source
# File lib/has_uuid/active_record/reflection.rb, line 20 def foreign_uuid @foreign_uuid ||= options[:foreign_uuid] || derive_foreign_uuid end
primary_uuid_column()
click to toggle source
Private Instance Methods
derive_foreign_uuid()
click to toggle source
# File lib/has_uuid/active_record/reflection.rb, line 29 def derive_foreign_uuid if belongs_to? "#{name}_uuid" elsif options[:as] "#{options[:as]}_uuid" else active_record.name.foreign_key end end
primary_uuid(klass)
click to toggle source
# File lib/has_uuid/active_record/reflection.rb, line 25 def primary_uuid(klass) klass.primary_uuid || raise(UnknownPrimaryKey.new(klass)) end