morse_fields_validator 1.1.3 → 1.1.4
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: 772c87166c71d64095891661212b6f7fa2c5bab6
|
4
|
+
data.tar.gz: ec28227fd013659d54cb7c2e06f874f18571007f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eab1cbcf3c0248ca6fc3f30565c1b46bdb7768741738649e4558ef16b87c78db34eddd0390ad52afb18afb133cd5f040550a81164bece4876096d1130adf8fc
|
7
|
+
data.tar.gz: 204dea299691ecb6136fe820bea7069f1e0fe3e994d3c65b20f7f08f80b14ad8fa053cd77508739ead0d58a6b123dc65c1bf4f673a87c4d6463763707effb423
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morse_fields_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Terry S
|
@@ -156,7 +156,6 @@ files:
|
|
156
156
|
- bin/console
|
157
157
|
- bin/setup
|
158
158
|
- lib/morse_fields_validator.rb
|
159
|
-
- lib/morse_fields_validator/fields_validator.rb
|
160
159
|
- lib/morse_fields_validator/version.rb
|
161
160
|
- morse_fields_validator.gemspec
|
162
161
|
homepage: https://github.com/morsedigital/morse_fields_validator
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module FieldsValidator
|
2
|
-
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
included do
|
6
|
-
validate :validate_column_names if respond_to?(:validate)
|
7
|
-
end
|
8
|
-
|
9
|
-
class_methods do
|
10
|
-
def validate_required_attributes
|
11
|
-
required_attributes.each do |a|
|
12
|
-
validates a.to_sym, presence: true
|
13
|
-
end if required_attributes.any?
|
14
|
-
end
|
15
|
-
|
16
|
-
def required_attributes
|
17
|
-
(defined?(super) and super.is_a?(Array)) ? super : []
|
18
|
-
end
|
19
|
-
|
20
|
-
def required_database_fields
|
21
|
-
(defined?(super) and super.is_a?(Array)) ? super : []
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def validate_column_names
|
29
|
-
self.class.required_database_fields.each { |rdf| errors_add(rdf, "does not have a column in the database.") unless self.class.column_names.include?(rdf)} if self.class.required_database_fields.any?
|
30
|
-
end
|
31
|
-
end
|