Sha256: a074c96eb6d7c3c9522e891b2405d392e731e36136c57e63285ce79853cbe726

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 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 == 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

2 entries across 2 versions & 1 rubygems

Version Path
rails-ext-0.2.11 lib/rails_ext/mongo_mapper.rb
rails-ext-0.2.10 lib/rails_ext/mongo_mapper.rb