One Thing
require first_and_only
[:thing].first_and_only! # => :thing
Too Many Things
require first_and_only
[1,2].first_and_only!
# => Enumerable::FirstAndOnly::LengthNotOne: 2
Not Enough Things
require first_and_only
[].first_and_only!
# => Enumerable::FirstAndOnly::LengthNotOne: 0
Works With ActiveRecord
require first_and_only
MyModel.count # => 0
MyModel.where(some: "query").first_and_only!
# => Enumerable::FirstAndOnly::LengthNotOne: 0
Enumerable doesn't define length, just count.
Calling count on a huge or infinite Range would be problematic. Perhaps you should only extend Array.