Module: IntegerHash::Rails::InstanceMethods

Defined in:
lib/integer_hash/rails.rb

Instance Method Summary collapse

Instance Method Details

#reload(options = nil) ⇒ Object

Override ActiveRecord::Persistence#reload passing in an options flag with { no_hashed_id: true }



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/integer_hash/rails.rb', line 41

def reload(options = nil)
  options = (options || {}).merge(no_hashed_id: true)

  clear_aggregation_cache
  clear_association_cache

  fresh_object =
    if options && options[:lock]
      self.class.unscoped { self.class.lock(options[:lock]).find(id, options) }
    else
      self.class.unscoped { self.class.find(id, options) }
    end

  @attributes = fresh_object.instance_variable_get('@attributes')
  @new_record = false
  self
end

#to_paramObject



35
36
37
# File 'lib/integer_hash/rails.rb', line 35

def to_param
  IntegerHash.encode(self.id).to_s
end