Class: Machinist::SequelAdapter
Class Method Summary collapse
- .assigned_attributes_without_associations(lathe) ⇒ Object
- .class_for_association(object, attribute) ⇒ Object
- .has_association?(object, attribute) ⇒ Boolean
Class Method Details
.assigned_attributes_without_associations(lathe) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/machinist/sequel.rb', line 15 def self.assigned_attributes_without_associations(lathe) attributes = {} lathe.assigned_attributes.each_pair do |attribute, value| association = lathe.object.class.association_reflection(attribute) if association && association[:type] == :many_to_one key = association[:key] || association.default_key attributes[key] = value.send(association.primary_key) else attributes[attribute] = value end end attributes end |
.class_for_association(object, attribute) ⇒ Object
11 12 13 |
# File 'lib/machinist/sequel.rb', line 11 def self.class_for_association(object, attribute) object.class.association_reflection(attribute).associated_class end |
.has_association?(object, attribute) ⇒ Boolean
7 8 9 |
# File 'lib/machinist/sequel.rb', line 7 def self.has_association?(object, attribute) object.class.associations.include?(attribute) end |