opengovernment/askthem

View on GitHub
app/models/committee.rb

Summary

Maintainability
A
0 mins
Test Coverage
# Billy
class Committee
  include Mongoid::Document

  belongs_to :metadatum, foreign_key: "state"

  # Returns the committee"s name.
  #
  # @return [String] the committee"s name
  # @note From Popolo.
  def name
    read_attribute(:subcommittee) || read_attribute(:committee)
  end

  # Returns the committee"s members.
  #
  # @return the committee"s members as scope
  # @note We do this because the OpenStates database is inconsistent.
  def people
    ids = read_attribute(:members).map { |x| x["leg_id"] }.compact
    return Person.in(id: []) unless ids.present?

    Person.in(id: ids)
  end
end