ClassMethods

Constants

Methods

#association_key?

def association_key?(key)
  association_method_keys.include?(key.to_sym)
end
#extract_association_attributes!

Extracts keys from attributes hash which are associations of the model TODO: Validate separately that relationships are getting the right values? Perhaps also store the values and persist relationships on save?

def extract_association_attributes!(attributes)
  return unless contains_association?(attributes)
  attributes.each_with_object({}) do |(key, _), result|
    result[key] = attributes.delete(key) if self.association_key?(key)
  end
end