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



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

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

Instance Method Details

#abort_if_dependenciesObject

used on before_destroy



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

def abort_if_dependencies
  throw(:abort) if has_dependencies?
end

#has_dependencies?Boolean

Returns:

  • (Boolean)


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

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



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

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