Module: SpatialFeatures::FeatureImport

Extended by:
ActiveSupport::Concern
Included in:
DelayedFeatureImport
Defined in:
lib/spatial_features/has_spatial_features/feature_import.rb

Instance Method Summary collapse

Instance Method Details

#update_features!(skip_invalid: false, options: {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spatial_features/has_spatial_features/feature_import.rb', line 12

def update_features!(skip_invalid: false, options: {})
  options = options.reverse_merge(spatial_features_options).reverse_merge(:import => {})

  ActiveRecord::Base.transaction do
    imports = spatial_feature_imports(options[:import], options[:make_valid])
    cache_key = Digest::MD5.hexdigest(imports.collect(&:cache_key).join)

    return if features_cache_key_matches?(cache_key)

    run_callbacks :update_features do
      import_features(imports)
      validate_features!(imports, skip_invalid)
      set_features_cache_key(cache_key)
    end

    return true
  end
end