Class: ActiveRecordNestedScope::Node::PolymorphicType

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord_nested_scope/node.rb

Instance Method Summary collapse

Constructor Details

#initialize(node, reflection) ⇒ PolymorphicType

Returns a new instance of PolymorphicType.



77
78
79
80
# File 'lib/activerecord_nested_scope/node.rb', line 77

def initialize(node, reflection)
  @node = node
  @reflection = reflection
end

Instance Method Details

#resolveObject



82
83
84
85
86
87
88
# File 'lib/activerecord_nested_scope/node.rb', line 82

def resolve
  types = @node.klass.unscoped.group(@reflection.foreign_type).pluck(@reflection.foreign_type).compact
  types.map do |type|
    klass = resolve_source_type(type)&.safe_constantize
    [klass, type] if klass
  end.compact
end