# File lib/traits/attribute/key.rb, line 7 def primary_key? column_definition.try(:primary) || active_record.primary_key == column_definition.name || type == :primary_key end
module Traits::Attribute::Key
Public Instance Methods
foreign_key?()
click to toggle source
# File lib/traits/attribute/key.rb, line 13 def foreign_key? attr_name = name attr_translates = active_record.attribute_features[attr_name].try(:translates_with_globalize?) model.associations.any? do |assoc| if assoc.belongs_to? if attr_translates && assoc.features.translates_with_globalize? assoc.features.globalize_translatable.translation_from_key_name == attr_name else assoc.from_key_name == attr_name end end end end
key?()
click to toggle source
# File lib/traits/attribute/key.rb, line 28 def key? primary_key? || foreign_key? || polymorphic_key? end
primary_key?()
click to toggle source
to_hash()
click to toggle source
Calls superclass method
# File lib/traits/attribute/key.rb, line 32 def to_hash super.merge!( key: key?, primary_key: primary_key?, foreign_key: foreign_key? ) end