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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/lib/highlighter/serializer.rb +12 -5
- data/lib/highlighter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc57165cc3381a2749507abc7746f95d2ede9786820b7ff3e8d2f9624981fd66
|
4
|
+
data.tar.gz: 593a5b19b6d616a407dd7b214186c43d3d478514f2607b318957485e717dcb21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70557187e4553b5049f2bf15da03c5f40710b6cc5daf133c15190d51d01193272f147d91e14b7c43a632c832abcfef2325cd2ae5b20608a3f95080c2525dc45d
|
7
|
+
data.tar.gz: 9601811f3dc47ef0396432d4fa949d1098a95dee414e7d3e921f59ee8662ce3a884d1a453e0434698c8763b2127d4b3b77630f3cf6e34ace048d944528eafbd3
|
data/Gemfile.lock
CHANGED
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.
|
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
|
-
|
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
|
-
|
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
|
data/lib/highlighter/version.rb
CHANGED
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.
|
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-
|
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:
|