Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend EveryPolitician Index with a legislature method #15316

Open
octopusinvitro opened this issue Sep 1, 2016 · 1 comment
Open

Extend EveryPolitician Index with a legislature method #15316

octopusinvitro opened this issue Sep 1, 2016 · 1 comment

Comments

@octopusinvitro
Copy link
Contributor

octopusinvitro commented Sep 1, 2016

Problem

At the moment, to pass a house to a Page constructor, we have to do a bit of a dance like this:

  subject do
    country = index_at_known_sha.country('united-states-of-america')
    house   = country.legislature('senate')
    Page::HouseDownload.new(
      house: house,
      index: index_at_known_sha
    )
  end

This adds a bit of complexity and raises the flog score a bit.

Proposed Solution

It would be nice if we could add a method to the lib/everypolitician_extensions.rb to extend the Everypolitician::Index with a method that allows you to pass a country and a house slug.

module IndexExtension
  def legislature(country_slug, legislature_slug)
    # ...
  end
end

So that you can do

    Page::HouseDownload.new(
      house: index_at_known_sha.legislature('united-states-of-america', 'senate'),
      index: index_at_known_sha
    )

Acceptance Criteria

house = index_at_known_sha.legislature('united-states-of-america', 'senate')
house.country.name 
# United States of America
house.name
# Senate
@octopusinvitro octopusinvitro self-assigned this Sep 1, 2016
@tmtmtmtm
Copy link
Contributor

tmtmtmtm commented Sep 1, 2016

👍

Would the method work if it were just called legislature? country_legislature is a bit of a mouthful.

@octopusinvitro octopusinvitro changed the title Extend EveryPolitician Index with a country_legislature method Extend EveryPolitician Index with a legislature method Sep 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants