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



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

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

Instance Method Details

#abort_if_dependenciesObject

used on before_destroy



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

def abort_if_dependencies
  throw(:abort) if has_dependencies?
end

#has_dependencies?Boolean

Returns:

  • (Boolean)


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

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



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

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