hipaa-enum 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92593243e719414a6ca60bd62709eed2317f2977
4
- data.tar.gz: f37843109e0971ddb90e05ccbf8a9eb9b813aba1
3
+ metadata.gz: 47417d4abf6feb3799a686883e042257f3d42a39
4
+ data.tar.gz: ccc871962873010d54a7c45b4a7b4b9082ff940f
5
5
  SHA512:
6
- metadata.gz: 14e002387e8f64906c13017a801246a2b8528adf69bd0aadafacd811c6007671905cfb5a3d838d616c429d8decfd281c2492ab6649fbc2482a3c2c7b570b4855
7
- data.tar.gz: 65b1de8219731e814b8c359fbe049276fbea5f54d17caa43ecdbc59a800d96986faf409fe35c288b2995c1afe7daa48e4c177273da0b8b083a290101d08c87f6
6
+ metadata.gz: 707be5d088ab6a78b0033b236af1f90f2cb1d85f21884b7e2c28e8e9dc03348ddd17953a2ddff9faf038c30379687b098b9dfa492de7fc2520251620a0a72518
7
+ data.tar.gz: 3588be762c356de672e60d303fab98224e50dcfe3f0fc0234f4d41b668c306ef4b6cf379f88bc9b757ca263a78ade026a9fb7ff63a1c35a5f8100e79f8807252
Binary file
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.description = %q{Heavily inspired by DDH's ActiveRecord::Enum, this little library is there to help you cut down the cruft in your models and make the world a happier place at the same time.}
13
13
  spec.summary = %q{Sweet enum sugar for your Mongoid documents}
14
- spec.homepage = "https://github.com/kennethrosales/hippa-enum"
14
+ spec.homepage = "https://github.com/kennethrosales/hipaa-enum"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files`.split($/)
@@ -0,0 +1,19 @@
1
+ module Hipaa
2
+ module Enum
3
+ class Configuration
4
+ attr_accessor :field_name_prefix
5
+
6
+ def initialize
7
+ self.field_name_prefix = "_"
8
+ end
9
+ end
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield(configuration) if block_given?
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ module Hipaa
2
+ module Enum
3
+ module Validators
4
+ class MultipleValidator < ActiveModel::EachValidator
5
+ def validate_each(record, attribute, values)
6
+ values = Array(values)
7
+
8
+ if options[:allow_nil]
9
+ add_error_message record, attribute if !all_included?(values, options[:in])
10
+ else
11
+ add_error_message record, attribute if values.empty? || !all_included?(values, options[:in])
12
+ end
13
+ end
14
+
15
+ def add_error_message(record, attribute)
16
+ record.errors[attribute] << (options[:message] || "is not in #{options[:in].join ", "}")
17
+ end
18
+
19
+ def all_included?(values, allowed)
20
+ (values - allowed).empty?
21
+ end
22
+
23
+ def self.kind
24
+ :custom
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Hipaa
2
2
  module Enum
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hipaa-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kennethrosales
@@ -85,10 +85,13 @@ files:
85
85
  - Rakefile
86
86
  - bin/console
87
87
  - bin/setup
88
+ - hipaa-enum-0.1.0.gem
88
89
  - hipaa-enum.gemspec
89
90
  - lib/hipaa/enum.rb
91
+ - lib/hipaa/enum/configuration.rb
92
+ - lib/hipaa/enum/validators/multiple_validator.rb
90
93
  - lib/hipaa/enum/version.rb
91
- homepage: https://github.com/kennethrosales/hippa-enum
94
+ homepage: https://github.com/kennethrosales/hipaa-enum
92
95
  licenses:
93
96
  - MIT
94
97
  metadata: {}