Module: Lite::Uxid::Record::Obfuscateid::ClassMethods

Defined in:
lib/lite/uxid/record/obfuscateid.rb

Instance Method Summary collapse

Instance Method Details

#find_by_uxid(uxid) ⇒ Object



19
20
21
22
# File 'lib/lite/uxid/record/obfuscateid.rb', line 19

def find_by_uxid(uxid)
  decoded_id = Lite::Uxid::Reversible::Obfuscateid.decode(uxid)
  find_by(id: decoded_id)
end

#find_by_uxid!(uxid) ⇒ Object

Raises:

  • (ActiveRecord::RecordNotFound)


24
25
26
27
28
29
# File 'lib/lite/uxid/record/obfuscateid.rb', line 24

def find_by_uxid!(uxid)
  record = find_by_uxid(uxid)
  return record unless record.nil?

  raise ActiveRecord::RecordNotFound
end