Class: Decidim::Elections::Trustee

Inherits:
ApplicationRecord show all
Defined in:
decidim-elections/app/models/decidim/elections/trustee.rb

Overview

The data store for a trustee in the Decidim::Elections component. It stores a public key and has a reference to Decidim::User.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(user) ⇒ Object


18
19
20
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 18

def self.for(user)
  find_by(user: user)
end

.trustee?(user) ⇒ Boolean

Returns:

  • (Boolean)

14
15
16
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 14

def self.trustee?(user)
  exists?(user: user)
end

Instance Method Details

#bulletin_board_slugObject

The bulletin_board_slug is used as `unique_id` on the Bulletin Board, where the “authority.name” gets added as identification. If the organization name would be missing, it could result in an error, when two organizations inside the same “authority” have a trustee with the same name.


30
31
32
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 30

def bulletin_board_slug
  "#{organization.name.parameterize}-#{slug}"
end

#slugObject


22
23
24
# File 'decidim-elections/app/models/decidim/elections/trustee.rb', line 22

def slug
  name.parameterize
end