Sha256: dabab1c20e212e9270d3b0e369fceb7d8511ac1aec71ff524336b39b2cf6bc3b
Contents?: true
Size: 1.33 KB
Versions: 3
Compression:
Stored size: 1.33 KB
Contents
module Replication module Process def self.extended(model_class) model_class.class_eval do include Model end end # Include or extend it. We work with both. def self.included(model_class) model_class.extend self end def can_replicate(pairs_method = :attributes, **options) @@replication_config = Class.new(Config).new(self) default_options = Replication.defaults modules = [:semi_conservative] # required module modules.concat([].push(options.delete(:with)).flatten).compact! @@replication_config.pairs_method = pairs_method @@replication_config.set default_options.merge(options) @@replication_config.with modules end def new_from_strand(id=nil, **options) if id strand = replication_config.strand_class.to_adapter.get!(id) else strand = replication_config.strand_class.to_adapter.find_first(options) end new(strand.pairs) if strand end def replication_config @@replication_config end module Model def strand_class replication_config.strand_class end def replication_config self.class.replication_config end private def _strand_attributes send(replication_config.pairs_method).deep_symbolize_keys end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
replication-0.3.2 | lib/replication/process.rb |
replication-0.3.1 | lib/replication/process.rb |
replication-0.3.0 | lib/replication/process.rb |