netroots-ruby-votesmart 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 1
4
+ :patch: 2
@@ -4,6 +4,8 @@ module VoteSmart
4
4
 
5
5
  attr_accessor :id, :name, :office_id, :state_id
6
6
 
7
+ attr_accessor :office
8
+
7
9
  set_attribute_map "districtId" => :id, "name" => :name, "officeId" => :office_id, "stateId" => :state_id
8
10
 
9
11
  def number
@@ -4,12 +4,16 @@ module VoteSmart
4
4
 
5
5
  attr_accessor :id, :type_id, :level_id, :branch_id, :name, :title, :short_title
6
6
 
7
+ attr_accessor :office
8
+
7
9
  set_attribute_map "officeId" => :id, "officeTypeId" => :type_id, "officeLevelId" => :level_id,
8
10
  "officeBranchId" => :branch_id, "name" => :name, "title" => :title, "shortTitle" => :short_title
9
11
 
10
12
  def districts_by_state_id state_id
11
13
  @districts_by_state ||= {}
12
- @districts_by_state[state_id] ||= District.find_all_by_office_id_and_state_id(self.id, state_id)
14
+ districts = District.find_all_by_office_id_and_state_id(self.id, state_id)
15
+ districts.each { |district| district.office = self }
16
+ @districts_by_state[state_id] ||= districts
13
17
  end
14
18
 
15
19
  def district_by_state_id_and_number state_id, number
@@ -20,7 +24,9 @@ module VoteSmart
20
24
 
21
25
  def official_by_state_id state_id
22
26
  @official_by_state ||= {}
23
- @official_by_state[state_id] ||= Official.find_by_office_id_and_state_id(self.id, state_id)
27
+ official = Official.find_by_office_id_and_state_id(self.id, state_id)
28
+ official.office = self if official
29
+ @official_by_state[state_id] ||= official
24
30
  end
25
31
 
26
32
  def self.all
@@ -3,7 +3,9 @@ module VoteSmart
3
3
  class Official < Common
4
4
 
5
5
  attr_accessor :id, :first_name, :nick_name, :middle_name, :last_name, :suffix, :title,
6
- :election_parties, :office_parties, :district_id, :district_name, :state_id, :district
6
+ :election_parties, :office_parties, :district_id, :district_name, :state_id
7
+
8
+ attr_accessor :district, :office
7
9
 
8
10
  set_attribute_map "candidateId" => :id, "firstName" => :first_name, "nickName" => :nick_name,
9
11
  "middleName" => :middle_name, "lastName" => :last_name, "suffix" => :suffix,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netroots-ruby-votesmart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Cunning