Sha256: 99f7b55fb621278cfc99e7b28eeddbce696153236db8603688bf96855608812a

Contents?: true

Size: 685 Bytes

Versions: 3

Compression:

Stored size: 685 Bytes

Contents

# require 'mm-paginate'

# 
# dom_id
# 
# MongoMapper::Document.class_eval do
#   def dom_id
#     new_record? ? "new_#{self.class.name.underscore}" : "#{id}"
#   end
# end

# 
# cache
#
MongoMapper::Document::InstanceMethods.class_eval do
  def cache
    @cache ||= {}
  end
  
  def clear_cache
    @cache = {}
  end
  
  def reload_with_cache
    @cache.clear if @cache
    reload_without_cache
  end
  alias_method_chain :reload, :cache
end

# 
# ObjectID
# 
Mongo::ObjectID.class_eval do 
  def == other
    self.to_s == other.to_s
  end
  
  def to_yaml *args
    to_s.to_yaml *args
  end
end

# String.class_eval do
#   def to_mongo_id
#     ObjectId.to_mongo self
#   end
# end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-ext-0.2.15 lib/rails_ext/mongo_mapper.rb
rails-ext-0.2.14 lib/rails_ext/mongo_mapper.rb
rails-ext-0.2.13 lib/rails_ext/mongo_mapper.rb