Module: ActiveModel::Embedding::Associations::ClassMethods
- Defined in:
- lib/active_model/embedding/associations.rb
Instance Method Summary collapse
- #embedded_associations ⇒ Object
- #embeds_many(attr_name, class_name: nil, cast_type: nil, collection: nil) ⇒ Object
- #embeds_one(attr_name, class_name: nil, cast_type: nil) ⇒ Object
Instance Method Details
#embedded_associations ⇒ Object
60 61 62 |
# File 'lib/active_model/embedding/associations.rb', line 60 def class_variable_get :@@embedded_associations end |
#embeds_many(attr_name, class_name: nil, cast_type: nil, collection: nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/active_model/embedding/associations.rb', line 33 def (attr_name, class_name: nil, cast_type: nil, collection: nil) class_name = cast_type ? nil : class_name || infer_class_name_from(attr_name) attribute :"#{attr_name}", :document, class_name: class_name, cast_type: cast_type, collection: collection || true, context: self.to_s attr_name nested_attributes_for attr_name end |
#embeds_one(attr_name, class_name: nil, cast_type: nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/active_model/embedding/associations.rb', line 47 def (attr_name, class_name: nil, cast_type: nil) class_name = cast_type ? nil : class_name || infer_class_name_from(attr_name) attribute :"#{attr_name}", :document, class_name: class_name, cast_type: cast_type, context: self.to_s attr_name nested_attributes_for attr_name end |