plutus
plutus copied to clipboard
Support for Mongoid
I'm opening this issue in order to keep track of updating / abstracting plutus to support Mongoid. I'd like to take an approach that will support other persistance mechanisms later on (Redis for example)
I think there are a number of questions to address prior to proceeding. I'll try to list a few, and please add any others that you can think of.
- How do we abstract out the models?
- Should the persistance mechanism be based on the parent app, or configurable without regard to app.
- Currently transactions support a "commercial document" relation which assume the parent app has a persisted model that we wish to relate to a transaction. If the persistance mechanisms are different, how do we handle that?
I'm not that familiar with Mongoid myself, but I'm under the impression that it is using ActiveModel under the hood, which means that it should already share an interface with ActiveRecord and anything else that extends ActiveModel. That being the case, I'm thinking that we simply have a Factory Class that generates the appropriate impl based on whatever configuration method we choose. Something like:
module Plutus
module Factory
case Plutus.persistence
when :active_record
class Transaction < Plutus::ActiveRecordPersistence::Transaction
end
when :mongoid
class Transaction < Plutus::MongoidPersistence::Transaction
end
else
raise "not implemented"
end
end
end
Controllers and what not then call Plutus::Factory:::Transaction.new
or Plutus::Factory::Transaction.find(params)
, etc.
This seems like a fine implementation to me, generally. We aim to play with it a bit and see where the cracks are...
+1 on mongoid support
So just an update - isotope11's fork has mongo support and we're using it in production, but we never did the work to get it mainline'd because the developer that was working on it isn't here anymore. If anyone wants to get that merged, we'll help any way we can :)
@knewter any hopes this is still active and I can help merge to plutus?
/cc @mbulat
@rileytg @mbulat
That fork/branch is here if I'm not mistaken. It looks like only 7 of 11 commits pertain to this feature. Is this still a desired feature?
+1 for Mongoid support.
Is someone working on implementing Mongoid for Plutus?