Class: Decidim::Area

Inherits:
ApplicationRecord show all
Includes:
Loggable, Traceable, TranslatableResource
Defined in:
app/models/decidim/area.rb

Overview

Areas are used in Assemblies to help users know which is the Area of a participatory space.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_presenter_class_for(_log) ⇒ Object



28
29
30
# File 'app/models/decidim/area.rb', line 28

def self.log_presenter_class_for(_log)
  Decidim::AdminLog::AreaPresenter
end

Instance Method Details

#abort_if_dependenciesObject

used on before_destroy



48
49
50
# File 'app/models/decidim/area.rb', line 48

def abort_if_dependencies
  throw(:abort) if has_dependencies?
end

#has_dependencies?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
# File 'app/models/decidim/area.rb', line 36

def has_dependencies?
  Decidim.participatory_space_registry.manifests.any? do |manifest|
    manifest
      .participatory_spaces
      .call(organization)
      .any? do |space|
      space.respond_to?(:area) && space.decidim_area_id == id
    end
  end
end

#translated_nameObject



32
33
34
# File 'app/models/decidim/area.rb', line 32

def translated_name
  Decidim::AreaPresenter.new(self).translated_name
end