Class: Associationist::Builder::CollectionAssociation

Inherits:
ActiveRecord::Associations::Builder::CollectionAssociation
  • Object
show all
Defined in:
lib/associationist/builder/collection_association.rb

Class Method Summary collapse

Class Method Details

.create_reflection(model, name, scope, options, extension = nil) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/associationist/builder/collection_association.rb', line 16

def self.create_reflection(model, name, scope, options, extension = nil)
  raise ArgumentError, "association names must be a Symbol" unless name.kind_of?(Symbol)

  validate_options(options)

  case
  when ActiveRecord.version >= Gem::Version.new('6.0.0')
    scope = build_scope(scope)
  else
    scope = build_scope(scope, extension)
  end
  Reflection::CollectionReflection.new(name, scope, options, model)
end

.macroObject



4
5
6
# File 'lib/associationist/builder/collection_association.rb', line 4

def self.macro
  :has_many
end

.valid_dependent_optionsObject



12
13
14
# File 'lib/associationist/builder/collection_association.rb', line 12

def self.valid_dependent_options
  [:destroy, :delete_all, :nullify, :restrict_with_error, :restrict_with_exception]
end

.valid_options(options) ⇒ Object



8
9
10
# File 'lib/associationist/builder/collection_association.rb', line 8

def self.valid_options(options)
  super + [:associationist]
end