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

Version Path
effective_polls-0.7.2 app/helpers/effective_polls_helper.rb
effective_polls-0.7.1 app/helpers/effective_polls_helper.rb
effective_polls-0.7.0 app/helpers/effective_polls_helper.rb
effective_polls-0.6.2 app/helpers/effective_polls_helper.rb
effective_polls-0.6.1 app/helpers/effective_polls_helper.rb
effective_polls-0.6.0 app/helpers/effective_polls_helper.rb
effective_polls-0.5.6 app/helpers/effective_polls_helper.rb
effective_polls-0.5.5 app/helpers/effective_polls_helper.rb
effective_polls-0.5.4 app/helpers/effective_polls_helper.rb
effective_polls-0.5.3 app/helpers/effective_polls_helper.rb
effective_polls-0.5.2 app/helpers/effective_polls_helper.rb
effective_polls-0.5.1 app/helpers/effective_polls_helper.rb