Module: Synchronisable::DSL::Associations::ClassMethods
- Defined in:
- lib/synchronisable/dsl/associations.rb
Instance Method Summary collapse
-
#associations_for(attrs) ⇒ Hash<Synchronisable::Association, Array>
Builds hash with association as key and array of ids as value.
- #inherited(subclass) ⇒ Object
Instance Method Details
#associations_for(attrs) ⇒ Hash<Synchronisable::Association, Array>
Builds hash with association as key and array of ids as value.
33 34 35 36 37 38 |
# File 'lib/synchronisable/dsl/associations.rb', line 33 def associations_for(attrs) ensure_required_associations(attrs) intersection = self.associations.map { |key, _| key } & attrs.keys Hash[intersection.map { |key| [self.associations[key], [*attrs[key]]] }] end |
#inherited(subclass) ⇒ Object
14 15 16 17 |
# File 'lib/synchronisable/dsl/associations.rb', line 14 def inherited(subclass) super subclass.associations = {} end |