location 0.0.1 → 0.1.0
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: f41922279600670cf0eda74410ac5c15252ef970
|
4
|
+
data.tar.gz: 9090ba682f5b4f59662fa9f6380d265bf881fcbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7214776f86d06f7b71a0beafba8bfb53ae758e95e23441921b657af8e5a01513f11fe8a62bf921c0f16ea461e8b39bdd206212f8ca3935dd9224303c3a4f5eb
|
7
|
+
data.tar.gz: 00e312c8dbb1fa5a20049887b0250e6c2de7e23dc579d65409a18bb3e321179a756dff9e36d245a207469c1fc2ee12c81e609647fe238677b5c744c1ee320f0a
|
@@ -1,13 +1,15 @@
|
|
1
|
+
require 'super_form'
|
2
|
+
|
1
3
|
module Location
|
2
4
|
class AddressForm
|
3
|
-
include
|
5
|
+
include SuperForm
|
4
6
|
|
5
7
|
def self.normalizable_attributes
|
6
8
|
%i{state city district}
|
7
9
|
end
|
8
10
|
|
9
11
|
def self.default_presence_attributes
|
10
|
-
%i{postal_code address district
|
12
|
+
%i{postal_code address district}
|
11
13
|
end
|
12
14
|
|
13
15
|
def self.string_attributes
|
@@ -18,8 +20,8 @@ module Location
|
|
18
20
|
%i{latitude longitude}
|
19
21
|
end
|
20
22
|
|
21
|
-
string_attributes.each { |attr|
|
22
|
-
float_attributes.each { |attr|
|
23
|
+
string_attributes.each { |attr| field attr, Field::Text }
|
24
|
+
float_attributes.each { |attr| field attr, Field::Float }
|
23
25
|
|
24
26
|
(string_attributes + float_attributes).each do |attr|
|
25
27
|
validates attr, presence: true, if: ->(a){ a.presence[attr] }
|
@@ -99,7 +101,8 @@ module Location
|
|
99
101
|
|
100
102
|
district = update_attribute(@model, :district)
|
101
103
|
city = update_attribute(district, :city)
|
102
|
-
|
104
|
+
|
105
|
+
update_attribute(city, :state)
|
103
106
|
end
|
104
107
|
|
105
108
|
def update_attribute(parent, attr)
|
data/lib/location/finder.rb
CHANGED
@@ -47,6 +47,18 @@ module Location
|
|
47
47
|
concat_type_to_address
|
48
48
|
end
|
49
49
|
|
50
|
+
def to_hash(options = {})
|
51
|
+
attributes = instance_variables.map do |k|
|
52
|
+
k.to_s.gsub(/^@/, '').to_sym
|
53
|
+
end
|
54
|
+
|
55
|
+
only = Array(options[:only] || attributes).map!(&:to_sym)
|
56
|
+
|
57
|
+
attributes.each_with_object({}) do |k, a|
|
58
|
+
a[k] = send(k) if only.include?(k)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
50
62
|
private
|
51
63
|
|
52
64
|
def concat_type_to_address
|
data/lib/location/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: location
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago A. Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - '='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 1.3.8
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: super_form
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.1'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: rspec-rails
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|