Sha256: 3d641cff758ca6ceb6711f52c78cf76b926228b44b25aa4a5c880bc1edbf2933
Contents?: true
Size: 624 Bytes
Versions: 4
Compression:
Stored size: 624 Bytes
Contents
module Ohm # Dirt cheap ::first and ::last support. # # @example # # class Post < Ohm::Model # include Ohm::Boundaries # end # # post1 = Post.create # post2 = Post.create # post1 == Post.first # # => true # # post2 == Post.last # # => true module Boundaries def self.included(base) base.extend ClassMethods end module ClassMethods def first(opts = {}) find(opts).sort(:start => 0, :limit => 1).first end def last(opts = {}) find(opts).sort(:start => 0, :limit => 1, :order => "DESC").first end end end end
Version data entries
4 entries across 4 versions & 1 rubygems