Class: ActiveRecord::Associations::SpatialAssociationScope
- Inherits:
-
AssociationScope
- Object
- AssociationScope
- ActiveRecord::Associations::SpatialAssociationScope
- Defined in:
- lib/activerecord-spatial/associations/active_record.rb
Overview
:nodoc:
Constant Summary collapse
- INSTANCE =
create
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.get_bind_values(owner, chain) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/activerecord-spatial/associations/active_record.rb', line 13 def get_bind_values(owner, chain) binds = [] last_reflection = chain.last if last_reflection.type binds << owner.class.polymorphic_name end chain.each_cons(2).each do |reflection, next_reflection| if reflection.type binds << next_reflection.klass.polymorphic_name end end binds end |
.scope(association) ⇒ Object
9 10 11 |
# File 'lib/activerecord-spatial/associations/active_record.rb', line 9 def scope(association) ActiveRecord::Associations::SpatialAssociationScope::INSTANCE.scope(association) end |
Instance Method Details
#last_chain_scope(scope, reflection, owner) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/activerecord-spatial/associations/active_record.rb', line 30 def last_chain_scope(scope, reflection, owner) = { class: reflection.klass } if reflection.geom.is_a?(Hash) [:value] = owner[reflection.geom[:name]] .merge!(reflection.geom) else [:value] = owner[reflection.geom] [:name] = reflection.geom end table = reflection.aliased_table scope = scope.send("st_#{reflection.relationship}", , reflection.) if reflection.type polymorphic_type = transform_value(owner.class.polymorphic_name) scope = apply_scope(scope, table, reflection.type, polymorphic_type) end scope end |