postal_address 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2499c8eb67851e9f520f4617be1237950cd8d1f1
|
4
|
+
data.tar.gz: 9ad9cb07b425aa9bb65953658811e292b8283ec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cc7ca58f44d13de08c8965b43b276a5c01ed95ab1b9e5838132b359bff4eb432128fa06a08e43863e78b0a2963276f6f133a0f477a68f4a517f898ddcb8a173
|
7
|
+
data.tar.gz: fccf1064bc4ad2348a1ae747d56d22c1872fe4e06201343055b02f856d4d8d2da976d4d1c6c955f1a6a797099364efeaf75d89fba1734217f8588a154dc29f93
|
@@ -9,11 +9,11 @@ class PostalAddress
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def formats
|
12
|
-
@formats ||=
|
12
|
+
@formats ||= load_yaml('address_formats')
|
13
13
|
end
|
14
14
|
|
15
15
|
def country_names
|
16
|
-
@country_names ||=
|
16
|
+
@country_names ||= load_yaml('country_names')
|
17
17
|
end
|
18
18
|
|
19
19
|
def attributes
|
@@ -32,5 +32,9 @@ class PostalAddress
|
|
32
32
|
def alias_attribute_writer(original, aliases)
|
33
33
|
aliases.each { |name| alias_method :"#{name}=", :"#{original}=" }
|
34
34
|
end
|
35
|
+
|
36
|
+
def load_yaml(filename)
|
37
|
+
YAML.load_file(File.join(File.dirname(__FILE__), "..", "..", "data", "#{filename}.yml"))
|
38
|
+
end
|
35
39
|
end
|
36
40
|
end
|
@@ -26,6 +26,10 @@ class PostalAddress
|
|
26
26
|
def country
|
27
27
|
@country = self.class.country_names[country_code] unless in_home_country?
|
28
28
|
end
|
29
|
+
|
30
|
+
def in_home_country?
|
31
|
+
self.class.home_country == country_code
|
32
|
+
end
|
29
33
|
|
30
34
|
private
|
31
35
|
|
@@ -37,10 +41,6 @@ class PostalAddress
|
|
37
41
|
self.class.formats[country_code] || self.class.formats[state ? 'us' : 'de']
|
38
42
|
end
|
39
43
|
|
40
|
-
def in_home_country?
|
41
|
-
self.class.home_country == country_code
|
42
|
-
end
|
43
|
-
|
44
44
|
def attributes(html=false)
|
45
45
|
self.class.attributes.inject({}) do |hash, (key, attribute)|
|
46
46
|
value = public_send(key)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postal_address
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Melchert
|
@@ -117,3 +117,4 @@ test_files:
|
|
117
117
|
- spec/postal_address_spec.rb
|
118
118
|
- spec/spec_helper.rb
|
119
119
|
- spec/virtus_integration_spec.rb
|
120
|
+
has_rdoc:
|