u-attributes 0.11.0 → 0.12.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
  SHA256:
3
- metadata.gz: 72e9cbaceb087cd97c5cf3a46b705f52d3664d96018851fda83d455dc59aaa36
4
- data.tar.gz: 36238187591d0662c2212ea7fd3e1e5192d5785c2f1f59f57731d2f704e2a78b
3
+ metadata.gz: '0981953778c6a7130c83e54de1e8c5a992def3ee434b673cfc80c5cb2fb65298'
4
+ data.tar.gz: 6219cc89e480e32fd28091999b882566aa6374f7e2c9b27a1dffab1881f8ad79
5
5
  SHA512:
6
- metadata.gz: f00dd1f663f7364c28743e33c8812f683a8a4837c42636b2289a179ca9a11a3935f4c7a443e688d0ecd57181f970afb4d37c7b06c823100a79c481ecc6cabae4
7
- data.tar.gz: d86e8e5b6689e524fdfb72133e1f209d946726a109574df20a2aaa92a239fd123e973636c50bb4ca45c0de72533b107ca95b197f95bcde6520afeb37deaa7e42
6
+ metadata.gz: e09afedf86b00b99c76bacc9ace249177259b7ed62e3452bef4b7418f08be6ba75cc1f5c5487015d102b4677f2c9cd23bba9221547dde5f0f600ad47a4a98a45
7
+ data.tar.gz: b284987930d5092a3158a112d2c6e17f11b6cfb873acdc73023560592c5fcc03e29b331097be49b171c3ac1524895510db14cef1bd7c0d6546801b2f6c0e1350
data/.travis.sh ADDED
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rake test
4
+
5
+ ACTIVEMODEL_VERSION='3.2' bundle update
6
+ ACTIVEMODEL_VERSION='3.2' bundle exec rake test
7
+
8
+ ACTIVEMODEL_VERSION='4.0' bundle update
9
+ ACTIVEMODEL_VERSION='4.0' bundle exec rake test
10
+
11
+ ACTIVEMODEL_VERSION='4.1' bundle update
12
+ ACTIVEMODEL_VERSION='4.1' bundle exec rake test
13
+
14
+ ACTIVEMODEL_VERSION='4.2' bundle update
15
+ ACTIVEMODEL_VERSION='4.2' bundle exec rake test
16
+
17
+ ACTIVEMODEL_VERSION='5.0' bundle update
18
+ ACTIVEMODEL_VERSION='5.0' bundle exec rake test
19
+
20
+ ACTIVEMODEL_VERSION='5.1' bundle update
21
+ ACTIVEMODEL_VERSION='5.1' bundle exec rake test
22
+
23
+ ACTIVEMODEL_VERSION='5.2' bundle update
24
+ ACTIVEMODEL_VERSION='5.2' bundle exec rake test
data/.travis.yml CHANGED
@@ -14,5 +14,5 @@ before_install:
14
14
  install: bundle install --jobs=3 --retry=3
15
15
  env:
16
16
  - DISABLE_SIMPLECOV=true
17
- script: ./run-tests.sh
17
+ script: ./.travis.sh
18
18
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- u-attributes (0.11.0)
4
+ u-attributes (0.12.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -266,9 +266,7 @@ p Person.new(name: 'John').attributes # {"age"=>nil, "name"=>"John"}
266
266
 
267
267
  ## Built-in extensions
268
268
 
269
- You can use the method `Micro::Attributes.features()` to combine and require only the features that better fit your needs.
270
-
271
- Note: The method `Micro::Attributes.with()` is an alias for `Micro::Attributes.features()`.
269
+ You can use the method `Micro::Attributes.features()` or `Micro::Attributes.with()` to combine and require only the features that better fit your needs.
272
270
 
273
271
  ### Usage
274
272
 
@@ -276,6 +274,9 @@ Note: The method `Micro::Attributes.with()` is an alias for `Micro::Attributes.f
276
274
  #----------------------------------#
277
275
  # Via Micro::Attributes.features() #
278
276
  #----------------------------------#
277
+
278
+ # Loading specific features
279
+
279
280
  class Job
280
281
  include Micro::Attributes.features(:diff)
281
282
 
@@ -287,6 +288,18 @@ class Job
287
288
  end
288
289
  end
289
290
 
291
+ # Loading all features
292
+ # ---
293
+
294
+ class Job
295
+ include Micro::Attributes.features
296
+
297
+ attributes :id, state: 'sleeping'
298
+ end
299
+
300
+ # Note:
301
+ # If `Micro::Attributes.features()` be invoked without arguments, a module with all features will be returned.
302
+
290
303
  # --------------------------------------------------------------------#
291
304
  # Using the .with() method alias and adding the initialize extension. #
292
305
  # --------------------------------------------------------------------#
@@ -296,6 +309,13 @@ class Job
296
309
  attributes :id, state: 'sleeping'
297
310
  end
298
311
 
312
+ # Note:
313
+ # The method `Micro::Attributes.with()` will raise an exception if no arguments/features were declared.
314
+ #
315
+ # class Job
316
+ # include Micro::Attributes.with() # ArgumentError (Invalid feature name! Available options: diff, initialize, activemodel_validations)
317
+ # end
318
+
299
319
  #---------------------------------------#
300
320
  # Via Micro::Attributes.to_initialize() #
301
321
  #---------------------------------------#
@@ -50,6 +50,10 @@ module Micro
50
50
 
51
51
  private_constant :OPTIONS
52
52
 
53
+ def self.all
54
+ ActiveModelValidationsAndDiffAndInitialize
55
+ end
56
+
53
57
  def self.fetch(names)
54
58
  option = OPTIONS[names.map { |name| name.to_s.downcase }.sort.join(':')]
55
59
  return option if option
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Micro
4
4
  module Attributes
5
- VERSION = "0.11.0"
5
+ VERSION = "0.12.0"
6
6
  end
7
7
  end
@@ -29,10 +29,13 @@ module Micro
29
29
  features(*options)
30
30
  end
31
31
 
32
- def self.features(*names)
32
+ def self.with(*names)
33
33
  Features.fetch(names)
34
34
  end
35
- singleton_class.send(:alias_method, :with, :features)
35
+
36
+ def self.features(*names)
37
+ names.empty? ? Features.all : Features.fetch(names)
38
+ end
36
39
 
37
40
  def attributes=(arg)
38
41
  self.class.attributes_data(AttributesUtils.hash_argument!(arg)).each do |name, value|
data/run-tests.sh CHANGED
@@ -1,22 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
- ACTIVEMODEL_VERSION='3.2' bundle update
4
- ACTIVEMODEL_VERSION='3.2' bundle exec rake test
3
+ git checkout -- Gemfile.lock
5
4
 
6
- ACTIVEMODEL_VERSION='4.0' bundle update
7
- ACTIVEMODEL_VERSION='4.0' bundle exec rake test
5
+ source $(dirname $0)/.travis.sh
8
6
 
9
- ACTIVEMODEL_VERSION='4.1' bundle update
10
- ACTIVEMODEL_VERSION='4.1' bundle exec rake test
11
-
12
- ACTIVEMODEL_VERSION='4.2' bundle update
13
- ACTIVEMODEL_VERSION='4.2' bundle exec rake test
14
-
15
- ACTIVEMODEL_VERSION='5.0' bundle update
16
- ACTIVEMODEL_VERSION='5.0' bundle exec rake test
17
-
18
- ACTIVEMODEL_VERSION='5.1' bundle update
19
- ACTIVEMODEL_VERSION='5.1' bundle exec rake test
20
-
21
- ACTIVEMODEL_VERSION='5.2' bundle update
22
- ACTIVEMODEL_VERSION='5.2' bundle exec rake test
7
+ git checkout -- Gemfile.lock
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: u-attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".gitignore"
36
+ - ".travis.sh"
36
37
  - ".travis.yml"
37
38
  - CODE_OF_CONDUCT.md
38
39
  - Gemfile