Class: ActiveEntity::Associations::Embeds::Builder::SingularAssociation
- Inherits:
-
Association
- Object
- Association
- ActiveEntity::Associations::Embeds::Builder::SingularAssociation
- Defined in:
- lib/active_entity/associations/embeds/builder/singular_association.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary
Constants inherited from Association
Class Method Summary collapse
- .define_accessors(model, reflection) ⇒ Object
-
.define_constructors(mixin, name) ⇒ Object
Defines the (build|create)_association methods for belongs_to or has_one association.
-
.valid_options(options) ⇒ Object
:nodoc:.
Methods inherited from Association
Class Method Details
.define_accessors(model, reflection) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/active_entity/associations/embeds/builder/singular_association.rb', line 11 def self.define_accessors(model, reflection) super mixin = model.generated_association_methods name = reflection.name define_constructors(mixin, name) if reflection.constructable? end |
.define_constructors(mixin, name) ⇒ Object
Defines the (build|create)_association methods for belongs_to or has_one association
20 21 22 23 24 25 26 |
# File 'lib/active_entity/associations/embeds/builder/singular_association.rb', line 20 def self.define_constructors(mixin, name) mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 def build_#{name}(*args, &block) association(:#{name}).build(*args, &block) end CODE end |
.valid_options(options) ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/active_entity/associations/embeds/builder/singular_association.rb', line 7 def self.() super + [:inverse_of, :required] end |