bullet_train 1.3.21 → 1.3.22

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
  SHA256:
3
- metadata.gz: 0bd65c9439489fabb38d86f03b70a4483de90b810664a9e6d6449d5b70197525
4
- data.tar.gz: d736aa3ce04d0631dc266d45ba99d12be8533b424352c0123f9e65b8103d770c
3
+ metadata.gz: 347c8bc91b3b401f88551f4e20464258313548a54bbcfc8568088cfb3eea401b
4
+ data.tar.gz: f12fd053f264a5cd60c9789195cd0ced4b171febfa96bfbdd2bf3b020fec6241
5
5
  SHA512:
6
- metadata.gz: 41d6586cfe91972ac76797039864439843b1946df4071c2900e6cfcf1e4ef593dc1423ef1e0274a578553f13e708fd426e1a3855c419a488a7c553f6305a0bdc
7
- data.tar.gz: e3b364be2ae23ac494e8d919b33796b52238d9f4708f06112f5235b017a488f3ef539332492c23d5686dc8a98203fbca8caf3659ced41874201cb8e5d94c359e
6
+ metadata.gz: e86a8f1861ee560b385397be2034e0933bbf020f24a1a909eec9a25e239291915aacebc74a8dddfc3172dd4d1e48f2526169101df369d321108e3e50dcc987bf
7
+ data.tar.gz: 21433ad6bccf6e919838e239141b3aa27840c8c04cfe9bcf6ce9b3fc804c1168599fea7f6e6dbe1bc0d11059c6ee596e3e5bd49731411880967499b06157592a
@@ -0,0 +1,24 @@
1
+ class Address < ApplicationRecord
2
+ extend ActiveHash::Associations::ActiveRecordExtensions
3
+
4
+ include Addresses::Base
5
+ # 🚅 add concerns above.
6
+
7
+ # 🚅 add belongs_to associations above.
8
+
9
+ # 🚅 add has_many associations above.
10
+
11
+ # 🚅 add oauth providers above.
12
+
13
+ # 🚅 add has_one associations above.
14
+
15
+ # 🚅 add scopes above.
16
+
17
+ # 🚅 add validations above.
18
+
19
+ # 🚅 add callbacks above.
20
+
21
+ # 🚅 add delegations above.
22
+
23
+ # 🚅 add methods above.
24
+ end
@@ -0,0 +1,22 @@
1
+ class Addresses::Continent < ApplicationHash
2
+ include Addresses::Continents::Base
3
+ # 🚅 add concerns above.
4
+
5
+ # 🚅 add belongs_to associations above.
6
+
7
+ # 🚅 add has_many associations above.
8
+
9
+ # 🚅 add oauth providers above.
10
+
11
+ # 🚅 add has_one associations above.
12
+
13
+ # 🚅 add scopes above.
14
+
15
+ # 🚅 add validations above.
16
+
17
+ # 🚅 add callbacks above.
18
+
19
+ # 🚅 add delegations above.
20
+
21
+ # 🚅 add methods above.
22
+ end
@@ -0,0 +1,22 @@
1
+ class Addresses::Country < ApplicationHash
2
+ include Addresses::Countries::Base
3
+ # 🚅 add concerns above.
4
+
5
+ # 🚅 add belongs_to associations above.
6
+
7
+ # 🚅 add has_many associations above.
8
+
9
+ # 🚅 add oauth providers above.
10
+
11
+ # 🚅 add has_one associations above.
12
+
13
+ # 🚅 add scopes above.
14
+
15
+ # 🚅 add validations above.
16
+
17
+ # 🚅 add callbacks above.
18
+
19
+ # 🚅 add delegations above.
20
+
21
+ # 🚅 add methods above.
22
+ end
@@ -0,0 +1,22 @@
1
+ class Addresses::Region < ApplicationHash
2
+ include Addresses::Regions::Base
3
+ # 🚅 add concerns above.
4
+
5
+ # 🚅 add belongs_to associations above.
6
+
7
+ # 🚅 add has_many associations above.
8
+
9
+ # 🚅 add oauth providers above.
10
+
11
+ # 🚅 add has_one associations above.
12
+
13
+ # 🚅 add scopes above.
14
+
15
+ # 🚅 add validations above.
16
+
17
+ # 🚅 add callbacks above.
18
+
19
+ # 🚅 add delegations above.
20
+
21
+ # 🚅 add methods above.
22
+ end
@@ -0,0 +1,22 @@
1
+ class Addresses::Subcontinent < ApplicationHash
2
+ include Addresses::Subcontinents::Base
3
+ # 🚅 add concerns above.
4
+
5
+ # 🚅 add belongs_to associations above.
6
+
7
+ # 🚅 add has_many associations above.
8
+
9
+ # 🚅 add oauth providers above.
10
+
11
+ # 🚅 add has_one associations above.
12
+
13
+ # 🚅 add scopes above.
14
+
15
+ # 🚅 add validations above.
16
+
17
+ # 🚅 add callbacks above.
18
+
19
+ # 🚅 add delegations above.
20
+
21
+ # 🚅 add methods above.
22
+ end
@@ -0,0 +1,18 @@
1
+ module Addresses::Base
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ belongs_to :addressable, polymorphic: true
6
+ belongs_to :country, class_name: "Addresses::Country"
7
+ belongs_to :region, class_name: "Addresses::Region"
8
+
9
+ def valid_address?
10
+ address_one? && city? && region_id? && country_id? && postal_code?
11
+ end
12
+
13
+ def all_blank?(attributes = {})
14
+ return super(attributes) unless attributes.empty?
15
+ !(address_one? || address_two? || city? || region_id? || country_id? || postal_code?)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module Addresses::Continents::Base
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/countries.json", File.dirname(__FILE__)))).map { |row| {id: row["region"], name: row["region"]} }.select { |row| row[:name].present? }.uniq
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Addresses::Countries::Base
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/countries.json", File.dirname(__FILE__))))
6
+
7
+ has_many :regions, class_name: "Addresses::Region"
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Addresses::Regions::Base
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/states.json", File.dirname(__FILE__))))
6
+
7
+ belongs_to :country, class_name: "Addresses::Country"
8
+
9
+ def modified_state_code
10
+ state_code.scan(/\D/).empty? ? name : state_code
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Addresses::Subcontinents::Base
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ self.data = JSON.parse(File.read(File.expand_path("../../../../../config/addresses/countries.json", File.dirname(__FILE__)))).map { |row| {id: row["subregion"], name: row["subregion"]} }.select { |row| row[:name].present? }.uniq
6
+ end
7
+ end
@@ -78,5 +78,14 @@ module Records::Base
78
78
  Rake::Task.task_defined?("db:seed") && Rake::Task["db:seed"].already_invoked
79
79
  end
80
80
 
81
+ def all_blank?(attributes = {})
82
+ attributes = self.attributes if attributes.empty?
83
+ attributes.all? do |key, value|
84
+ key == "_destroy" || value.blank? ||
85
+ value.is_a?(Hash) && all_blank?(value) ||
86
+ value.is_a?(Array) && value.all? { |val| all_blank?(val) }
87
+ end
88
+ end
89
+
81
90
  ActiveSupport.run_load_hooks :bullet_train_records_base, self
82
91
  end