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.
- data/VERSION.yml +1 -1
- data/lib/vote_smart/district.rb +2 -0
- data/lib/vote_smart/office.rb +8 -2
- data/lib/vote_smart/official.rb +3 -1
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/vote_smart/district.rb
CHANGED
data/lib/vote_smart/office.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
data/lib/vote_smart/official.rb
CHANGED
@@ -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
|
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,
|