Sha256: 43c23d594bbda0ed143725f0ac67fc3ce374d1c60b32c57ebb279964ff6d3df8
Contents?: true
Size: 575 Bytes
Versions: 2
Compression:
Stored size: 575 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 all.first end # @todo Add support for passing in conditions def last self[db.get(key(:id))] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ohm-contrib-0.0.16 | lib/ohm/contrib/boundaries.rb |
ohm-contrib-0.0.15 | lib/ohm/contrib/boundaries.rb |