Class: BigRecord::ArAssociations::ClassMethods::JoinDependency
- Inherits:
-
Object
- Object
- BigRecord::ArAssociations::ClassMethods::JoinDependency
- Defined in:
- lib/big_record/ar_associations.rb
Overview
:nodoc:
Defined Under Namespace
Classes: JoinAssociation, JoinBase
Instance Attribute Summary
-
- (Object) joins
readonly
Returns the value of attribute joins.
-
- (Object) reflections
readonly
Returns the value of attribute reflections.
-
- (Object) table_aliases
readonly
Returns the value of attribute table_aliases.
Instance Method Summary
- - (Object) aliased_table_names_for(table_name)
-
- (JoinDependency) initialize(base, associations, joins)
constructor
A new instance of JoinDependency.
- - (Object) instantiate(rows)
- - (Object) join_associations
- - (Object) join_base
Constructor Details
- (JoinDependency) initialize(base, associations, joins)
A new instance of JoinDependency
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 |
# File 'lib/big_record/ar_associations.rb', line 1284 def initialize(base, associations, joins) @joins = [JoinBase.new(base, joins)] @associations = associations @reflections = [] @base_records_hash = {} @base_records_in_order = [] @table_aliases = Hash.new { |aliases, table| aliases[table] = 0 } @table_aliases[base.table_name] = 1 build(associations) end |
Instance Attribute Details
- (Object) joins (readonly)
Returns the value of attribute joins
1282 1283 1284 |
# File 'lib/big_record/ar_associations.rb', line 1282 def joins @joins end |
- (Object) reflections (readonly)
Returns the value of attribute reflections
1282 1283 1284 |
# File 'lib/big_record/ar_associations.rb', line 1282 def reflections @reflections end |
- (Object) table_aliases (readonly)
Returns the value of attribute table_aliases
1282 1283 1284 |
# File 'lib/big_record/ar_associations.rb', line 1282 def table_aliases @table_aliases end |
Instance Method Details
- (Object) aliased_table_names_for(table_name)
1314 1315 1316 |
# File 'lib/big_record/ar_associations.rb', line 1314 def aliased_table_names_for(table_name) joins.select{|join| join.table_name == table_name }.collect{|join| join.aliased_table_name} end |
- (Object) instantiate(rows)
1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 |
# File 'lib/big_record/ar_associations.rb', line 1303 def instantiate(rows) rows.each_with_index do |row, i| primary_id = join_base.record_id(row) unless @base_records_hash[primary_id] @base_records_in_order << (@base_records_hash[primary_id] = join_base.instantiate(row)) end construct(@base_records_hash[primary_id], @associations, join_associations.dup, row) end return @base_records_in_order end |
- (Object) join_associations
1295 1296 1297 |
# File 'lib/big_record/ar_associations.rb', line 1295 def join_associations @joins[1..-1].to_a end |
- (Object) join_base
1299 1300 1301 |
# File 'lib/big_record/ar_associations.rb', line 1299 def join_base @joins[0] end |