Module: Decidim::Geocodable::RecordGeocoder

Defined in:
lib/decidim/geocodable.rb

Defined Under Namespace

Modules: Calculations

Class Method Summary collapse

Class Method Details

.search(query, options = {}) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/decidim/geocodable.rb', line 61

def self.search(query, options = {})
  if (util = utility)
    util.search(query, options.compact)
  else
    Geocoder.search(query, options)
  end
end

.utilityObject



53
54
55
56
57
58
59
# File 'lib/decidim/geocodable.rb', line 53

def self.utility
  return if @record.blank?
  return unless Decidim::Map.available?(:geocoding)
  return unless @record.respond_to?(:organization)

  Decidim::Map.geocoding(organization: @record.organization)
end

.with_record(record) ⇒ Object



46
47
48
49
50
51
# File 'lib/decidim/geocodable.rb', line 46

def self.with_record(record)
  @record = record
  yield
ensure
  @record = nil
end