morse_fields_validator 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/.fields_validator.rb.swp +0 -0
- data/lib/fields_validator.rb +33 -0
- data/lib/morse_fields_validator/version.rb +1 -1
- metadata +3 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d1d0992c09ee33d3d4c63b4cac5657530c8e06ff
         | 
| 4 | 
            +
              data.tar.gz: d849159a25b4aefaf8e98c788af18d631b00eeb8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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
         | 
    
        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.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
         |