nxt_support 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -0
- data/lib/nxt_support/refinements/crystalizer.rb +16 -0
- data/lib/nxt_support/refinements.rb +1 -0
- data/lib/nxt_support/version.rb +1 -1
- data/lib/nxt_support.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14151213160e609dc893ae3113a4cfb1eb452ad20f0fe99b7e604e1f20376971
|
4
|
+
data.tar.gz: 4fea5f3185b01a3730de9cf418c9c10b14c2bbc742eb5dcb0dbe28ee36ce6fdc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c96c5be6ec63d22ae72652f8ece297945a32ea0c4c972b03ec9234da864663f629c45ddd8bf76e1b26b2484744c25de91dbb0a1e4c18d44814b5620f9fac254c
|
7
|
+
data.tar.gz: 4d7b2944ede23aaf2e568d026bd193019a19b4bcd42ae45612c817c63882bf07d46c81bc6fbb6593833d4236d28a208cea2228e8047a4ae39336943fcf6d0ffe
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -307,6 +307,16 @@ NxtSupport::Crystalizer.new(collection: ['andy', 'scotty']).call # NxtSupport::C
|
|
307
307
|
NxtSupport::Crystalizer.new(collection: insurances, attribute: :effective_at).call # => shared effective_at or error in case of different effective_ats
|
308
308
|
```
|
309
309
|
|
310
|
+
or using the refinement
|
311
|
+
|
312
|
+
```ruby
|
313
|
+
using NxtSupport::Refinements::Crystalizer
|
314
|
+
|
315
|
+
['andy', 'andy'].crystalize # => 'andy'
|
316
|
+
```
|
317
|
+
|
318
|
+
Note that for Ruby versions < 3.0 it only refines the class `Array` instead of the module `Enumerable`.
|
319
|
+
|
310
320
|
#### NxtSupport::BirthDate
|
311
321
|
|
312
322
|
`NxtSupport::BirthDate` takes a date and provides some convenience methods related to age.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module NxtSupport
|
2
|
+
module Refinements
|
3
|
+
module Crystalizer
|
4
|
+
#
|
5
|
+
# For ruby versions < 3.0, refining a module that is already included isn't possible.
|
6
|
+
#
|
7
|
+
_refined_module_or_class = Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0') ? Array : Enumerable
|
8
|
+
|
9
|
+
refine _refined_module_or_class do
|
10
|
+
def crystalize(&block)
|
11
|
+
::NxtSupport::Crystalizer.new(collection: self, on_ambiguity: block).call
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "nxt_support/refinements/crystalizer"
|
data/lib/nxt_support/version.rb
CHANGED
data/lib/nxt_support.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nxt_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nils Sommer
|
@@ -177,6 +177,8 @@ files:
|
|
177
177
|
- lib/nxt_support/preprocessor.rb
|
178
178
|
- lib/nxt_support/preprocessors/downcase_preprocessor.rb
|
179
179
|
- lib/nxt_support/preprocessors/strip_preprocessor.rb
|
180
|
+
- lib/nxt_support/refinements.rb
|
181
|
+
- lib/nxt_support/refinements/crystalizer.rb
|
180
182
|
- lib/nxt_support/serializers.rb
|
181
183
|
- lib/nxt_support/serializers/has_time_attributes.rb
|
182
184
|
- lib/nxt_support/services.rb
|