Sha256: 0ae813defc9e512e3e63294ae34d4632863bf6c3974011e86fd4f3137f616fa5

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 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

1 entries across 1 versions & 1 rubygems

Version Path
rails-ext-0.2.7 lib/rails_ext/mongo_mapper.rb