Class: Decidim::Area

Inherits:
ApplicationRecord show all
Includes:
Loggable, Traceable
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



26
27
28
# File 'app/models/decidim/area.rb', line 26

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

Instance Method Details

#abort_if_dependenciesObject

used on before_destroy



46
47
48
# File 'app/models/decidim/area.rb', line 46

def abort_if_dependencies
  throw(:abort) if has_dependencies?
end

#has_dependencies?Boolean

Returns:

  • (Boolean)


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

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



30
31
32
# File 'app/models/decidim/area.rb', line 30

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