morse_fields_validator 1.1.4 → 1.1.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: 772c87166c71d64095891661212b6f7fa2c5bab6
4
- data.tar.gz: ec28227fd013659d54cb7c2e06f874f18571007f
3
+ metadata.gz: d1d0992c09ee33d3d4c63b4cac5657530c8e06ff
4
+ data.tar.gz: d849159a25b4aefaf8e98c788af18d631b00eeb8
5
5
  SHA512:
6
- metadata.gz: 9eab1cbcf3c0248ca6fc3f30565c1b46bdb7768741738649e4558ef16b87c78db34eddd0390ad52afb18afb133cd5f040550a81164bece4876096d1130adf8fc
7
- data.tar.gz: 204dea299691ecb6136fe820bea7069f1e0fe3e994d3c65b20f7f08f80b14ad8fa053cd77508739ead0d58a6b123dc65c1bf4f673a87c4d6463763707effb423
6
+ metadata.gz: 914a4e0ff2384206fe5965cf3e862ddf4c93be7254600bf1bd5962d555a8174a615a8d8fd9e379194d02626e08c1fb8fa9c0689446c65ec2ee6c87cc316d1599
7
+ data.tar.gz: e1bb468ea4cf59f7f61d51bdd78be378bf9212d1a8c18a90bc599b1ce60b335cb4e834b86d7c5650ebdb6211c3737deabec52932e75cee6fa52e2ccbb34a0d73
Binary file
@@ -0,0 +1,33 @@
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
+ if self.class.required_database_fields and self.class.required_database_fields.any?
30
+ 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?
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module MorseFieldsValidator
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
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
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry S
@@ -155,6 +155,8 @@ files:
155
155
  - Rakefile
156
156
  - bin/console
157
157
  - bin/setup
158
+ - lib/.fields_validator.rb.swp
159
+ - lib/fields_validator.rb
158
160
  - lib/morse_fields_validator.rb
159
161
  - lib/morse_fields_validator/version.rb
160
162
  - morse_fields_validator.gemspec