Module: RGeo::ActiveRecord::GeoTableDefinitions

Defined in:
lib/rgeo/active_record/common_adapter_elements.rb

Overview

Provide methods for each geometric subtype during table definitions.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



45
46
47
48
49
50
# File 'lib/rgeo/active_record/common_adapter_elements.rb', line 45

def self.included(base)
  base.class_eval do
    alias_method :method_missing_without_rgeo, :method_missing
    alias_method :method_missing, :method_missing_with_rgeo
  end
end

Instance Method Details

#method_missing_with_rgeo(method_name_, *args_, &block_) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rgeo/active_record/common_adapter_elements.rb', line 52

def method_missing_with_rgeo(method_name_, *args_, &block_)
  if @base.respond_to?(:spatial_column_constructor) && (info_ = @base.spatial_column_constructor(method_name_))
    info_ = info_.dup
    type_ = (info_.delete(:type) || method_name_).to_s
    opts_ = args_.extract_options!.merge(info_)
    args_.each do |name_|
      column(name_, type_, opts_)
    end
  else
    method_missing_without_rgeo(method_name_, *args_, &block_)
  end
end