Class: ActiveRecord::UnionRelation::Subquery::SingleModelName

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

Overview

A model name for a model that is not using single-table inheritance. In this case we use the model name itself as the discriminator and only need one entry in the mappings hash that maps records to the columns that we are pulling from the result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ SingleModelName

Returns a new instance of SingleModelName.



43
44
45
# File 'lib/active_record/union_relation.rb', line 43

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



41
42
43
# File 'lib/active_record/union_relation.rb', line 41

def name
  @name
end

Instance Method Details

#each_name {|name| ... } ⇒ Object

Yields:



47
48
49
# File 'lib/active_record/union_relation.rb', line 47

def each_name
  yield name
end

#to_sqlObject



51
52
53
# File 'lib/active_record/union_relation.rb', line 51

def to_sql
  Arel.sql("'#{name}'")
end