Sha256: 16c27882c8fc191f8c6870fe544fd86e56e7e40d1a0849100c56b93fa7134396
Contents?: true
Size: 710 Bytes
Versions: 12
Compression:
Stored size: 710 Bytes
Contents
module EffectivePollsHelper # Used by admin/polls form def effective_polls_audience_scope_collection(poll) klass = poll.try(:audience_class) raise('expected a poll with an audience_class') unless klass.try(:effective_polls_user?) resource = klass.new scopes = resource.poll_audience_scopes raise('expected poll audience scopes') unless scopes.kind_of?(Array) # Append the number of users in this scope scopes.map do |label, scope| relation = resource.poll_audience_scope(scope) raise("invalid poll_audience_scope for #{scope}") unless relation.kind_of?(ActiveRecord::Relation) ["#{label} (#{pluralize(relation.count, 'user')})", scope] end end end
Version data entries
12 entries across 12 versions & 1 rubygems