netroots-ruby-votesmart 0.2.3 → 0.2.4
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/candidate_office.rb +3 -3
- data/lib/vote_smart/official.rb +4 -0
- metadata +1 -1
data/VERSION.yml
CHANGED
@@ -5,9 +5,9 @@ module VoteSmart
|
|
5
5
|
attr_accessor :address, :phone, :notes
|
6
6
|
|
7
7
|
def initialize attributes
|
8
|
-
self.address = Address.new(attributes["address"])
|
9
|
-
self.phone = Phone.new(attributes["phone"])
|
10
|
-
self.notes = Notes.new(attributes["notes"])
|
8
|
+
self.address = Address.new(attributes["address"] || {})
|
9
|
+
self.phone = Phone.new(attributes["phone"] || {})
|
10
|
+
self.notes = Notes.new(attributes["notes"] || {})
|
11
11
|
end
|
12
12
|
|
13
13
|
end
|
data/lib/vote_smart/official.rb
CHANGED
@@ -27,6 +27,7 @@ module VoteSmart
|
|
27
27
|
def self.find_by_district district
|
28
28
|
official = find_by_district_id district.id
|
29
29
|
official.district = district if official
|
30
|
+
official.office = district.office if official
|
30
31
|
official
|
31
32
|
end
|
32
33
|
|
@@ -47,6 +48,9 @@ module VoteSmart
|
|
47
48
|
|
48
49
|
def self.find_all_by_address address, city, state, zip
|
49
50
|
placemark = Geocoding.get("#{address} #{city}, #{state} #{zip}").first
|
51
|
+
|
52
|
+
return [] unless placemark
|
53
|
+
|
50
54
|
state ||= placemark.administrative_area
|
51
55
|
|
52
56
|
placemark ? find_all_by_state_and_latitude_and_longitude(state, placemark.latitude, placemark.longitude) : []
|