order_already 0.2.1 → 0.3.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/order_already/version.rb +1 -1
- data/lib/order_already.rb +11 -2
- 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: 06d0792edcb48d855dd6d7fe7f7e7bd28ee198f6144a816e4b7594f49ea7fe32
|
4
|
+
data.tar.gz: bc0bb4eafc7c7f01bdbb90e3a5ab20b59abc74f797509f0da4f592ba946ca628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57752a7bf98a638194b27db452a8028e30cfe94e2490972ee3b9164e72c3e20e6fbb3db4db9c1b6e3a1987259daf29e69b78657578a42342d68377d11e127a50
|
7
|
+
data.tar.gz: 16d4471e24105b2641ff0640963e3de6a2eff56dc84e0ea104415b1b4cbbe77ab146fcb71df6938f60f4bf1158b5fcf0bdee2d7e2c22939a8209669c83455d29
|
data/Gemfile.lock
CHANGED
data/lib/order_already.rb
CHANGED
@@ -20,7 +20,8 @@ module OrderAlready
|
|
20
20
|
# data. Want to auto-alphabetize? Use a different serializer than the default.
|
21
21
|
#
|
22
22
|
# @return [Module] a module that wraps the attr_accessor methods for the given :attributes. In
|
23
|
-
# using a module, we have access to `super`; which is super convenient!
|
23
|
+
# using a module, we have access to `super`; which is super convenient! The module will
|
24
|
+
# also add a `#attribute_is_ordered_already?` method.
|
24
25
|
#
|
25
26
|
# @note In testing, you need to use `prepend` instead of `include`; but that may be a function of
|
26
27
|
# my specs.
|
@@ -42,9 +43,13 @@ module OrderAlready
|
|
42
43
|
# prepend OrderAlready.for(:subjects, serializer: Alphabetizer)
|
43
44
|
# end
|
44
45
|
def self.for(*attributes, serializer: InputOrderSerializer)
|
46
|
+
# Capturing the named attributes to create a local binding; this helps ensure we have that
|
47
|
+
# available in the later :attribute_is_ordered_already? method definition.
|
48
|
+
ordered_attributes = attributes.map(&:to_sym)
|
49
|
+
|
45
50
|
# By creating a module, we have access to `super`.
|
46
51
|
Module.new do
|
47
|
-
|
52
|
+
ordered_attributes.each do |attribute|
|
48
53
|
define_method(attribute) do
|
49
54
|
serializer.deserialize(super())
|
50
55
|
end
|
@@ -53,6 +58,10 @@ module OrderAlready
|
|
53
58
|
super(serializer.serialize(values))
|
54
59
|
end
|
55
60
|
end
|
61
|
+
|
62
|
+
define_method(:attribute_is_ordered_already?) do |attribute|
|
63
|
+
ordered_attributes.include?(attribute.to_sym)
|
64
|
+
end
|
56
65
|
end
|
57
66
|
end
|
58
67
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: order_already
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails-html-sanitizer
|