nandosola / dilithium-rb

A tiny framework to power your enterprise-ish stuff in Ruby
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

JSON datatype persistence #20

Open mcamou opened 10 years ago

mcamou commented 10 years ago

The currently-implemented Mapper uses Sequel to persist to relational databases. Implement a Mapper that can persist to JSON stores (i.e., MongoDB, PostgreSQL JSON datatype)

nandosola commented 10 years ago

This would be useful for non-state attributes (mainly configs). Usage example:

module AppConfig
  extend EmbeddableValue
     attribute :name, String
      #...
  end
end
class Foo < BaseEntity
  include AppConfig
  attribute :my_foo, String
  attribute : my_bar, String
  #...
end
#...
Dilithium::PersistenceService.configure do |service|
          service.entity_mappers(
            :default => :'EntityMapper::Sequel',
            :AppConfig => :'EntityMapper::Sequel::Json'
          )
        end

This is just pseudo-code. Should AppConfig be a reference? a child? Is class/module level enough? Maybe at attr level?

nandosola commented 10 years ago

Food for thought: