Sha256: d8adf9c038a0d993a134530ce75bd685cb3be5a963af6c4a26cf84131b758b15
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Replication module Modules module Association def self.included(model_class) model_class.accepts_nested_attributes_for *model_class.replication_config.options[:associations] end def strand_attributes super associations_to_replicate = self.class.replication_config.options[:associations] if associations_to_replicate if associations_to_replicate.last.class == Hash associations_to_replicate.pop end associations_to_replicate.each do |a| association_reflection = self.class.reflect_on_association(a) association_model = association_reflection.klass attributes_from_association = association_model.column_names.dup attributes_from_association.delete('id') attributes_from_association.delete(association_reflection.foreign_key) @strand_attributes.merge!({ "#{a}_attributes".to_sym => self.send(association_reflection.name).select(attributes_from_association).to_a.map(&:serializable_hash) }) end end @strand_attributes end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
replication-0.3.2 | lib/replication/modules/association.rb |