Sha256: 468b91a9783d68082add9b64c327cb9eb99b95a428e95bd5077244b084f08610
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Transit module Model module Hooks def deliver_as(type) scope = type.to_s.classify include Transit::Package.const_get(scope) Transit.track(self, type.to_sym) end def deliver_with(*opts) opts.map(&:to_s).map(&:classify).each do |t| begin include Transit::Model.const_get(t.pluralize) rescue NameError raise Transit::Errors::ResourceNotFound.new("You called deliver_with #{t.underscore} but no resource called #{t.pluralize} was found.") end end self.delivery_options |= opts.map!(&:to_s) end # Provide auto-incrementing functionality for any model def auto_increment include Transit::Model::AutoIncrement end end end end Mongoid::Document::ClassMethods.class_eval do include Transit::Model::Hooks include Transit::Model::Paginator::ClassMethods end Mongoid::Criteria.send :include, Transit::Model::Paginator::Criteria Mongoid::Document.send :include, Transit::Model::Paginator::Document
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
transit-0.0.2 | lib/transit/model/hooks.rb |