Class: ActiveRecord::UnionRelation::Subquery::MultiModelName

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/union_relation.rb

Overview

A model name for a model that is using single-table inheritance. In this case we use the inheritance column as the discriminator and need to include all of the subclasses in the mappings hash.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inheritance_column, names) ⇒ MultiModelName

Returns a new instance of MultiModelName.



62
63
64
65
# File 'lib/active_record/union_relation.rb', line 62

def initialize(inheritance_column, names)
  @inheritance_column = inheritance_column
  @names = names
end

Instance Attribute Details

#inheritance_columnObject (readonly)

Returns the value of attribute inheritance_column.



60
61
62
# File 'lib/active_record/union_relation.rb', line 60

def inheritance_column
  @inheritance_column
end

#namesObject (readonly)

Returns the value of attribute names.



60
61
62
# File 'lib/active_record/union_relation.rb', line 60

def names
  @names
end

Instance Method Details

#each_name(&block) ⇒ Object



67
68
69
# File 'lib/active_record/union_relation.rb', line 67

def each_name(&block)
  names.each(&block)
end

#to_sqlObject



71
72
73
# File 'lib/active_record/union_relation.rb', line 71

def to_sql
  Arel.sql(inheritance_column)
end