Class: Decidim::ActionDelegator::Setting
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::ActionDelegator::Setting
- Defined in:
- app/models/decidim/action_delegator/setting.rb
Overview
Contains the delegation settings of a consultation. Rather than a single attribute here a setting is the record itself: a bunch of configuration values.
Instance Method Summary collapse
- #destroyable? ⇒ Boolean
- #editable? ⇒ Boolean
- #email_required? ⇒ Boolean
- #ongoing? ⇒ Boolean
- #phone_required? ⇒ Boolean
- #state ⇒ Object
Instance Method Details
#destroyable? ⇒ Boolean
58 59 60 |
# File 'app/models/decidim/action_delegator/setting.rb', line 58 def destroyable? participants.empty? && ponderations.empty? && delegations.empty? end |
#editable? ⇒ Boolean
54 55 56 |
# File 'app/models/decidim/action_delegator/setting.rb', line 54 def editable? state != :closed end |
#email_required? ⇒ Boolean
66 67 68 |
# File 'app/models/decidim/action_delegator/setting.rb', line 66 def email_required? verify_with_email? || verify_with_both? end |
#ongoing? ⇒ Boolean
50 51 52 |
# File 'app/models/decidim/action_delegator/setting.rb', line 50 def ongoing? state == :ongoing end |
#phone_required? ⇒ Boolean
62 63 64 |
# File 'app/models/decidim/action_delegator/setting.rb', line 62 def phone_required? verify_with_phone? || verify_with_both? end |
#state ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'app/models/decidim/action_delegator/setting.rb', line 40 def state @state ||= if consultation.end_voting_date < Time.zone.now :closed elsif consultation.start_voting_date <= Time.zone.now :ongoing else :pending end end |