Class: Decidim::Scope
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::Scope
- Defined in:
- decidim-core/app/models/decidim/scope.rb
Overview
Scopes are used in some entities through Decidim to help users know which is the scope of a participatory process. (i.e. does it affect the whole city or just a district?)
Class Method Summary collapse
-
.top_level ⇒ Object
Scope to return only the top level scopes.
Instance Method Summary collapse
- #descendants ⇒ Object
-
#part_of_scopes ⇒ Object
Gets the scopes from the part_of list.
Class Method Details
.top_level ⇒ Object
Scope to return only the top level scopes.
Returns an ActiveRecord::Relation.
41 42 43 |
# File 'decidim-core/app/models/decidim/scope.rb', line 41 def self.top_level where parent_id: nil end |
Instance Method Details
#descendants ⇒ Object
45 46 47 |
# File 'decidim-core/app/models/decidim/scope.rb', line 45 def descendants organization.scopes.where("? = ANY(decidim_scopes.part_of)", id) end |
#part_of_scopes ⇒ Object
Gets the scopes from the part_of list
Returns an ActiveRecord::Relation.
52 53 54 |
# File 'decidim-core/app/models/decidim/scope.rb', line 52 def part_of_scopes organization.scopes.where(id: part_of) end |