Module: IntegerHash::Rails::ClassMethods

Defined in:
lib/integer_hash/rails.rb

Instance Method Summary collapse

Instance Method Details

#find(*args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/integer_hash/rails.rb', line 16

def find(*args)
  scope = args.slice!(0)
  options = args.slice!(0) || {}
  if has_encoded_id? && !options[:no_hashed_id]
    if scope.is_a?(Array)
      scope.map! {|a| IntegerHash.decode(a.to_i).to_s}
    else
      scope = IntegerHash.decode(scope.to_i).to_s
    end
  end
  super(scope)
end

#has_encoded_id?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/integer_hash/rails.rb', line 29

def has_encoded_id?
  true
end