Module: ModelConcerns::Protectable

Extended by:
ActiveSupport::Concern
Defined in:
lib/model_concerns/protectable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#fake_idObject



5
6
7
8
# File 'lib/model_concerns/protectable.rb', line 5

def fake_id
  return nil if self.id.nil?
  @fake_id ||= self.id ^ self.class.protect_seed
end

#reload(options = nil) ⇒ Object



14
15
16
17
18
# File 'lib/model_concerns/protectable.rb', line 14

def reload(options = nil)
  options = (options || {}).merge(real_id: true)
  self.id = self.fake_id
  super(options)
end

#to_paramObject



10
11
12
# File 'lib/model_concerns/protectable.rb', line 10

def to_param
  fake_id.to_s
end