Module: HasPublicId::ActiveRecord::InstanceMethods

Defined in:
lib/has_public_id/activerecord/mixin.rb

Instance Method Summary collapse

Instance Method Details

#initialize_public_idObject



10
11
12
13
14
15
# File 'lib/has_public_id/activerecord/mixin.rb', line 10

def initialize_public_id
  if has_attribute?(public_id_attr)
    read_attribute(public_id_attr) or
    write_attribute(public_id_attr, self.class.new_public_id)
  end
end

#public_id_attrObject



7
8
9
# File 'lib/has_public_id/activerecord/mixin.rb', line 7

def public_id_attr
  self.class.public_id_attr
end

#to_paramObject



4
5
6
# File 'lib/has_public_id/activerecord/mixin.rb', line 4

def to_param
  self.send(public_id_attr)
end