highlighter 0.3.0.pre.alpha → 0.4.0.pre.alpha

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: 0da81f118da4f0f966398170d013bfbde42783d862a416b668d28f7680036ea1
4
- data.tar.gz: b4419445f9c3427a7c65b4f12d138f17cc86f74d65587ee24ce45f3b8c0f09ab
3
+ metadata.gz: fc57165cc3381a2749507abc7746f95d2ede9786820b7ff3e8d2f9624981fd66
4
+ data.tar.gz: 593a5b19b6d616a407dd7b214186c43d3d478514f2607b318957485e717dcb21
5
5
  SHA512:
6
- metadata.gz: e7f0ef49bebdc089c5d0a11da23aaad9fcddb68dc5f21297b0505451ea0d4ea3e10345bf0884964d653567aa9c37ae61f7263a00f42c291d94270d14a6ffbb43
7
- data.tar.gz: 0ff8249c987ba58b2a6a585d0caa3e8655c17d0af07ce5599ad29126ccbf890f5f7719f6401946b5c87966ada2cb3757447d0788230e8a67c7fa1447b49f8d78
6
+ metadata.gz: 70557187e4553b5049f2bf15da03c5f40710b6cc5daf133c15190d51d01193272f147d91e14b7c43a632c832abcfef2325cd2ae5b20608a3f95080c2525dc45d
7
+ data.tar.gz: 9601811f3dc47ef0396432d4fa949d1098a95dee414e7d3e921f59ee8662ce3a884d1a453e0434698c8763b2127d4b3b77630f3cf6e34ace048d944528eafbd3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- highlighter (0.3.0.pre.alpha)
4
+ highlighter (0.4.0.pre.alpha)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -113,6 +113,21 @@ end
113
113
  full_name: "Kelly"
114
114
  }
115
115
  ```
116
+ Passing a list of fields:
117
+ ```ruby
118
+ class UserSerializer
119
+ include Highlighter::Serializer
120
+
121
+ attributes :id, :name
122
+ end
123
+ ```
124
+ ```ruby
125
+ {
126
+ id: 1,
127
+ name: "Kelly"
128
+ }
129
+ ```
130
+
116
131
  ## Development
117
132
 
118
133
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -16,7 +16,7 @@ module Highlighter
16
16
  return if @object.nil?
17
17
 
18
18
  Commands::ObjectSerializer.call(object: @object,
19
- attributes: self.class.attributes,
19
+ attributes: self.class.attribute_list,
20
20
  options: @options)
21
21
  end
22
22
  end
@@ -24,12 +24,19 @@ module Highlighter
24
24
  # Add methods to expose and set up attributes
25
25
  module ClassMethods
26
26
  def attribute(field, serializer: nil, rename_to: nil)
27
- instance_variable_set(:@attributes, []) unless instance_variable_defined?(:@attributes)
28
- instance_variable_get(:@attributes) << Attribute.new(field:, serializer:, rename_to:)
27
+ attribute_list << Attribute.new(field:, serializer:, rename_to:)
29
28
  end
30
29
 
31
- def attributes
32
- instance_variable_get(:@attributes)
30
+ def attributes(*fields)
31
+ fields.each do |field|
32
+ attribute_list << Attribute.new(field:)
33
+ end
34
+ end
35
+
36
+ def attribute_list
37
+ instance_variable_set(:@attribute_list, []) unless instance_variable_defined?(:@attribute_list)
38
+
39
+ instance_variable_get(:@attribute_list)
33
40
  end
34
41
  end
35
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Highlighter
4
- VERSION = "0.3.0-alpha"
4
+ VERSION = "0.4.0-alpha"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highlighter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.alpha
4
+ version: 0.4.0.pre.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Rodriguez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-03 00:00:00.000000000 Z
11
+ date: 2022-09-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Serializer ruby objects in simple and straightforward way
14
14
  email: