Module: Superstore::AttributeMethods::PrimaryKey::AttributeOverrides

Defined in:
lib/superstore/attribute_methods/primary_key.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



29
30
31
# File 'lib/superstore/attribute_methods/primary_key.rb', line 29

def attributes
  super.update(self.class.primary_key => id)
end

#idObject



20
21
22
23
24
25
26
27
# File 'lib/superstore/attribute_methods/primary_key.rb', line 20

def id
  value = super
  if value.nil?
    value = self.class._generate_key(self)
    @attributes.write_from_user(self.class.primary_key, value)
  end
  value
end