Class: Decidim::BulletinBoard::MessageIdentifier
- Inherits:
-
Object
- Object
- Decidim::BulletinBoard::MessageIdentifier
- Defined in:
- lib/decidim/bulletin_board/message_identifier.rb
Constant Summary collapse
- AUTHOR_TYPE =
{ a: :authority, b: :bulletin_board, t: :trustee, v: :voter }.freeze
- INVERTED_AUTHOR_TYPE =
AUTHOR_TYPE.invert.freeze
Class Method Summary collapse
- .format(unique_election_id, type_subtype, author_type, author_id) ⇒ Object
- .unique_election_id(authority_slug, election_id) ⇒ Object
Instance Method Summary collapse
- #author_id ⇒ Object
- #author_type ⇒ Object
- #authority_id ⇒ Object
- #election_id ⇒ Object
- #from_authority? ⇒ Boolean
- #from_trustee? ⇒ Boolean
- #from_voter? ⇒ Boolean
-
#initialize(message_id) ⇒ MessageIdentifier
constructor
A new instance of MessageIdentifier.
- #subtype ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #type_subtype ⇒ Object
- #unique_trustee_id(authority_slug, trustee_name) ⇒ Object
Constructor Details
#initialize(message_id) ⇒ MessageIdentifier
Returns a new instance of MessageIdentifier.
15 16 17 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 15 def initialize() @message_id = end |
Class Method Details
.format(unique_election_id, type_subtype, author_type, author_id) ⇒ Object
68 69 70 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 68 def format(unique_election_id, type_subtype, , ) "#{unique_election_id}.#{type_subtype}+#{INVERTED_AUTHOR_TYPE[]}.#{}" end |
.unique_election_id(authority_slug, election_id) ⇒ Object
72 73 74 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 72 def unique_election_id(, election_id) "#{}.#{election_id}" end |
Instance Method Details
#author_id ⇒ Object
35 36 37 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 35 def @author_id ||= .last end |
#author_type ⇒ Object
31 32 33 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 31 def @author_type ||= AUTHOR_TYPE[.first.to_sym] end |
#authority_id ⇒ Object
39 40 41 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 39 def @authority_id ||= elements[0] end |
#election_id ⇒ Object
43 44 45 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 43 def election_id @election_id ||= elements[0..1].join(".") end |
#from_authority? ⇒ Boolean
19 20 21 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 19 def == :authority end |
#from_trustee? ⇒ Boolean
23 24 25 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 23 def from_trustee? == :trustee end |
#from_voter? ⇒ Boolean
27 28 29 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 27 def from_voter? == :voter end |
#subtype ⇒ Object
51 52 53 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 51 def subtype @subtype ||= elements[3] end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 59 def to_s @message_id end |
#type ⇒ Object
47 48 49 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 47 def type @type ||= elements[2] end |
#type_subtype ⇒ Object
55 56 57 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 55 def type_subtype @type_subtype ||= [type, subtype].compact.join(".") end |
#unique_trustee_id(authority_slug, trustee_name) ⇒ Object
63 64 65 |
# File 'lib/decidim/bulletin_board/message_identifier.rb', line 63 def unique_trustee_id(, trustee_name) "#{}.#{trustee_name}" end |