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.
54 55 56 |
# File 'lib/active_record/union_relation.rb', line 54 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
52 53 54 |
# File 'lib/active_record/union_relation.rb', line 52 def name @name end |
Instance Method Details
#each_name {|name| ... } ⇒ Object
58 59 60 |
# File 'lib/active_record/union_relation.rb', line 58 def each_name yield name end |
#to_sql ⇒ Object
62 63 64 |
# File 'lib/active_record/union_relation.rb', line 62 def to_sql Arel.sql("'#{name}'") end |