Class: ROM::SQL::Plugin::Associates::AssociateOptions Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/sql/plugin/associates.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, relation, opts) ⇒ AssociateOptions

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AssociateOptions.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rom/sql/plugin/associates.rb', line 26

def initialize(name, relation, opts)
  @name = name
  @opts = { assoc: name, keys: opts[:key] }

  relation.associations.try(name) do |assoc|
    @assoc = assoc
    @opts.update(assoc: assoc, keys: assoc.join_keys(relation.__registry__))
  end

  @opts.update(parent: opts[:parent]) if opts[:parent]
end

Instance Attribute Details

#assocObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rom/sql/plugin/associates.rb', line 24

def assoc
  @assoc
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rom/sql/plugin/associates.rb', line 24

def name
  @name
end

#optsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/rom/sql/plugin/associates.rb', line 24

def opts
  @opts
end

Instance Method Details

#after?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


38
39
40
# File 'lib/rom/sql/plugin/associates.rb', line 38

def after?
  assoc.is_a?(Association::ManyToMany)
end

#ensure_valid(command) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/rom/sql/plugin/associates.rb', line 42

def ensure_valid(command)
  raise MissingJoinKeysError.new(command, name) unless opts[:keys]
end

#to_hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/rom/sql/plugin/associates.rb', line 46

def to_hash
  { associate: opts }
end