Class: ActiveRecord::UnionRelation::Subquery::SingleModelName
- Inherits:
-
Object
- Object
- ActiveRecord::UnionRelation::Subquery::SingleModelName
- 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #each_name {|name| ... } ⇒ Object
-
#initialize(name) ⇒ SingleModelName
constructor
A new instance of SingleModelName.
- #to_sql ⇒ Object
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
#name ⇒ Object (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
47 48 49 |
# File 'lib/active_record/union_relation.rb', line 47 def each_name yield name end |
#to_sql ⇒ Object
51 52 53 |
# File 'lib/active_record/union_relation.rb', line 51 def to_sql Arel.sql("'#{name}'") end |