Module: ActiveRecordSpatial::Associations::ClassMethods
- Defined in:
- lib/activerecord-spatial/associations.rb,
lib/activerecord-spatial/associations/base.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#has_many_spatially(name, scope = nil, options = {}, &extension) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/activerecord-spatial/associations.rb', line 9 def has_many_spatially(name, scope = nil, = {}, &extension) if scope.is_a?(Hash) = scope scope = nil end = () unless ActiveRecordSpatial::SpatialScopeConstants::RELATIONSHIPS.include?([:relationship].to_s) raise ArgumentError, %{Invalid spatial relationship "#{[:relationship]}", expected one of #{ActiveRecordSpatial::SpatialScopeConstants::RELATIONSHIPS.inspect}} end reflection = ActiveRecord::Associations::Builder::Spatial.build(self, name, scope, , &extension) if ActiveRecord::Reflection.respond_to?(:add_reflection) ActiveRecord::Reflection.add_reflection(self, name, reflection) end reflection end |