module MongoPersist::ClassMethods

Public Instance Methods

default_collection_name() click to toggle source
# File lib/mongo_persist/base.rb, line 71
def default_collection_name
  to_s.downcase.pluralize
end
from_mongo_hash(h) click to toggle source
# File lib/mongo_persist/base.rb, line 79
def from_mongo_hash(h)
  res = new_with_nil_args.tap { |x| x.from_mongo_hash(h) }
  res.after_mongo_load if res.respond_to?(:after_mongo_load)
  res
end
mongo_connection(ops) click to toggle source
# File lib/mongo_persist/base.rb, line 84
def mongo_connection(ops)
  ops.each { |k,v| send("#{k}=",v) }
end
new_with_nil_args() click to toggle source
# File lib/mongo_persist/base.rb, line 75
def new_with_nil_args
  args = (1..(instance_method(:initialize).arity)).map { |x| nil }
  new(*args)
end