Class: Decidim::ActionDelegator::Setting

Inherits:
ApplicationRecord show all
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

Instance Method Details

#destroyable?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


54
55
56
# File 'app/models/decidim/action_delegator/setting.rb', line 54

def editable?
  state != :closed
end

#email_required?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


50
51
52
# File 'app/models/decidim/action_delegator/setting.rb', line 50

def ongoing?
  state == :ongoing
end

#phone_required?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'app/models/decidim/action_delegator/setting.rb', line 62

def phone_required?
  verify_with_phone? || verify_with_both?
end

#stateObject



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