Skip to content

Instantly share code, notes, and snippets.

View dgollahon's full-sized avatar

Daniel Gollahon dgollahon

  • Cognito
  • San Francisco, California
View GitHub Profile
@dgollahon
dgollahon / sequel_one_extension.rb
Created October 28, 2016 21:24
A small extension to `sequel` to add a #one method to Dataset
# frozen_string_literal: true
#
# The one extension adds Dataset#one which performs a LIMIT(2) query and will raise a
# Sequel::NoMatchingRow if exactly one row is not returned.
module Sequel
module One
MSG = 'Expected query to produce exactly 1 row but received %<rows>s.'
def one