nxt_support 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 04156bb470e9230b1d2d6eb97b40ac553d6f54d945875eac31ed48148907ac29
4
- data.tar.gz: 4daca280e15ef43fdd8e465b39ec9810930ad66fdd668ce300bdfb9431f47e71
3
+ metadata.gz: 14151213160e609dc893ae3113a4cfb1eb452ad20f0fe99b7e604e1f20376971
4
+ data.tar.gz: 4fea5f3185b01a3730de9cf418c9c10b14c2bbc742eb5dcb0dbe28ee36ce6fdc
5
5
  SHA512:
6
- metadata.gz: 36e8e83265ea3d5accc6ff7fdd67221ea4d88c8e9b451e92dc7cc7806c0e8f9e0c44ec609d25d1ef13c04acca86a20196f0bd36921a470502243ceca551af90c
7
- data.tar.gz: bf5edfb86fdac8909c673405094179adcf0ca8200a7935c7bcde48e4e4b162f65cee2f7443b8cbec6b242c5f15120bd0da3c1b3cafff207f662c23ff89c8ccc4
6
+ metadata.gz: c96c5be6ec63d22ae72652f8ece297945a32ea0c4c972b03ec9234da864663f629c45ddd8bf76e1b26b2484744c25de91dbb0a1e4c18d44814b5620f9fac254c
7
+ data.tar.gz: 4d7b2944ede23aaf2e568d026bd193019a19b4bcd42ae45612c817c63882bf07d46c81bc6fbb6593833d4236d28a208cea2228e8047a4ae39336943fcf6d0ffe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nxt_support (0.2.0)
4
+ nxt_support (0.2.1)
5
5
  activerecord
6
6
  activesupport
7
7
  nxt_init
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"
@@ -1,3 +1,3 @@
1
1
  module NxtSupport
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.2.1".freeze
3
3
  end
data/lib/nxt_support.rb CHANGED
@@ -7,6 +7,7 @@ require "nxt_support/models"
7
7
  require "nxt_support/serializers"
8
8
  require "nxt_support/util"
9
9
  require "nxt_support/services"
10
+ require "nxt_support/refinements"
10
11
 
11
12
  module NxtSupport
12
13
  end
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.0
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