Sha256: 4d0bfbf0ce67776d343cf6efaf076f3df9bfcebbbcea2d89fb6dba725a163e38

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

# require 'mm-paginate'

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

# 
# attributes_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 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

2 entries across 2 versions & 1 rubygems

Version Path
rails-ext-0.2.9 lib/rails_ext/mongo_mapper.rb
rails-ext-0.2.8 lib/rails_ext/mongo_mapper.rb