Class: ActiveRecord::Associations::Builder::Association
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/builder/association.rb
Overview
:nodoc:
Direct Known Subclasses
Constant Summary collapse
- VALID_OPTIONS =
[ :class_name, :anonymous_class, :primary_key, :foreign_key, :dependent, :validate, :inverse_of, :strict_loading ].freeze
Class Attribute Summary collapse
-
.extensions ⇒ Object
Returns the value of attribute extensions.
Class Method Summary collapse
-
.build(model, name, scope, options, &block) ⇒ Object
:nodoc:.
- .create_reflection(model, name, scope, options, &block) ⇒ Object
Class Attribute Details
.extensions ⇒ Object
Returns the value of attribute extensions.
17 18 19 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/builder/association.rb', line 17 def extensions @extensions end |
Class Method Details
.build(model, name, scope, options, &block) ⇒ Object
:nodoc:
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/builder/association.rb', line 25 def self.build(model, name, scope, , &block) if model.dangerous_attribute_method?(name) raise ArgumentError, "You tried to define an association named #{name} on the model #{model.name}, but " \ "this will conflict with a method #{name} already defined by Active Record. " \ "Please choose a different association name." end reflection = create_reflection(model, name, scope, , &block) define_accessors model, reflection define_callbacks model, reflection define_validations model, reflection define_change_tracking_methods model, reflection reflection end |
.create_reflection(model, name, scope, options, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/associations/builder/association.rb', line 40 def self.create_reflection(model, name, scope, , &block) raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol) () extension = define_extensions(model, name, &block) [:extend] = [*[:extend], extension] if extension scope = build_scope(scope) ActiveRecord::Reflection.create(macro, name, scope, , model) end |