Module: MongoPersist::ClassMethods
- Defined in:
- lib/mongo_persist/base.rb
Instance Method Summary collapse
- #default_collection_name ⇒ Object
- #from_mongo_hash(h) ⇒ Object
- #mongo_connection(ops) ⇒ Object
- #new_with_nil_args ⇒ Object
Instance Method Details
#default_collection_name ⇒ Object
71 72 73 |
# File 'lib/mongo_persist/base.rb', line 71 def default_collection_name to_s.downcase.pluralize end |
#from_mongo_hash(h) ⇒ Object
79 80 81 82 83 |
# 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) ⇒ Object
84 85 86 |
# File 'lib/mongo_persist/base.rb', line 84 def mongo_connection(ops) ops.each { |k,v| send("#{k}=",v) } end |
#new_with_nil_args ⇒ Object
75 76 77 78 |
# 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 |