Module: Sequel::Plugins::HashId::DatasetMethods

Defined in:
lib/sequel/plugins/hash_id.rb

Instance Method Summary collapse

Instance Method Details

#with_hashid(hashid) ⇒ Object

Lookup a record with a hashid, returning nil if none is found



46
47
48
49
50
# File 'lib/sequel/plugins/hash_id.rb', line 46

def with_hashid(hashid)
  id ,= model.hasher.decode(hashid)

  self[id] if id
end

#with_hashid!(hashid) ⇒ Object

Lookup a record with a hashid, raising Sequel::NoMatchingError if not found



54
55
56
57
58
# File 'lib/sequel/plugins/hash_id.rb', line 54

def with_hashid!(hashid)
  id ,= model.hasher.decode(hashid)

  with_pk!(id)
end