Class: ProfileFieldTypes::Address
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
#children_count, #delete_cache, #key, #label, #orig_profileable, possible_types, #profileable, #underscored_type, #value
#readonly?
Class Method Details
.model_name ⇒ Object
6
|
# File 'app/models/profile_field_types/address.rb', line 6
def self.model_name; ProfileField.model_name; end
|
Instance Method Details
#city ⇒ Object
43
|
# File 'app/models/profile_field_types/address.rb', line 43
def city ; geo_information :city end
|
#clear_postal_address ⇒ Object
80
81
82
83
84
|
# File 'app/models/profile_field_types/address.rb', line 80
def clear_postal_address
self.profileable.profile_fields.where(type: "ProfileFieldTypes::Address").each do |address_field|
address_field.remove_flag :postal_address
end
end
|
#country ⇒ Object
41
|
# File 'app/models/profile_field_types/address.rb', line 41
def country ; geo_information :country end
|
#country_code ⇒ Object
42
|
# File 'app/models/profile_field_types/address.rb', line 42
def country_code ; geo_information :country_code end
|
#display_html ⇒ Object
26
27
28
|
# File 'app/models/profile_field_types/address.rb', line 26
def display_html
ActionController::Base.helpers.simple_format self.value
end
|
#find_geo_location ⇒ Object
18
19
20
|
# File 'app/models/profile_field_types/address.rb', line 18
def find_geo_location
@geo_location ||= GeoLocation.find_by_address(value)
end
|
#find_or_create_geo_location ⇒ Object
22
23
24
|
# File 'app/models/profile_field_types/address.rb', line 22
def find_or_create_geo_location
@geo_location ||= GeoLocation.find_or_create_by_address(value) if self.value && self.value != "—"
end
|
47
48
49
50
|
# File 'app/models/profile_field_types/address.rb', line 47
def geo_information( key )
return nil if self.value == "—"
geo_location.send( key ) if self.value
end
|
#geo_location ⇒ Object
14
15
16
|
# File 'app/models/profile_field_types/address.rb', line 14
def geo_location
find_or_create_geo_location
end
|
#geocode ⇒ Object
55
56
57
58
59
|
# File 'app/models/profile_field_types/address.rb', line 55
def geocode
return @geo_location.geocode if @geo_location
return @geo_location.geocode if find_geo_location
return find_or_create_geo_location
end
|
#geocoded? ⇒ Boolean
52
53
54
|
# File 'app/models/profile_field_types/address.rb', line 52
def geocoded?
(find_geo_location && @geo_location.geocoded?).to_b
end
|
#gmaps ⇒ Object
35
36
37
|
# File 'app/models/profile_field_types/address.rb', line 35
def gmaps
true
end
|
#gmaps4rails_address ⇒ Object
This is needed to display the map later.
31
32
33
|
# File 'app/models/profile_field_types/address.rb', line 31
def gmaps4rails_address
self.value
end
|
#latitude ⇒ Object
39
|
# File 'app/models/profile_field_types/address.rb', line 39
def latitude ; geo_information :latitude end
|
#longitude ⇒ Object
40
|
# File 'app/models/profile_field_types/address.rb', line 40
def longitude ; geo_information :longitude end
|
#plz ⇒ Object
45
|
# File 'app/models/profile_field_types/address.rb', line 45
def plz ; geo_information :plz end
|
#postal_address ⇒ Object
Allow to mark one address as primary postal address.
63
64
65
|
# File 'app/models/profile_field_types/address.rb', line 63
def postal_address
self.has_flag? :postal_address
end
|
#postal_address=(new_postal_address) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
|
# File 'app/models/profile_field_types/address.rb', line 66
def postal_address=(new_postal_address)
if new_postal_address != self.postal_address
if new_postal_address
self.clear_postal_address
self.add_flag :postal_address
else
self.remove_flag :postal_address
end
self.delete_cache
end
end
|
#postal_address? ⇒ Boolean
77
78
79
|
# File 'app/models/profile_field_types/address.rb', line 77
def postal_address?
self.postal_address
end
|
#postal_code ⇒ Object
44
|
# File 'app/models/profile_field_types/address.rb', line 44
def postal_code ; geo_information :postal_code end
|