eigindir 0.0.2 → 0.0.3
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/README.md +2 -2
- data/lib/eigindir/api.rb +2 -4
- data/lib/eigindir/version.rb +1 -1
- data/spec/tests/eigindir_spec.rb +7 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2857c676f78ba1237fce472c7ca0fbc228f47207
|
4
|
+
data.tar.gz: 5e20e1350e6b3e5d87f299cb1643144488010417
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07f91b296c273ecc2ef0fb3faf1effdff82dec5831e1470a2303f42a65c38a34048cf358cdc1307a68e7fa367da42f726ab46dfb8b69a11e3dea320cf8155f42
|
7
|
+
data.tar.gz: ec8c980f1a8d3dfd95ab9b8b07d52f22f8f640bc6b786f05c2095d3a15b1402bc8fa9be0c842c592617df3c5508151a2c3f2bdf359cde032a4008eac43635a0f
|
data/README.md
CHANGED
@@ -235,7 +235,7 @@ Because `nil` stands for *nothing*, it is not coerced by default:
|
|
235
235
|
class Foo
|
236
236
|
include Eigindir
|
237
237
|
|
238
|
-
attribute :bar, coerce:
|
238
|
+
attribute :bar, coerce: ->(value) { value.to_s }
|
239
239
|
end
|
240
240
|
|
241
241
|
foo = Foo.new
|
@@ -250,7 +250,7 @@ Use `strict: true` option to coerce `nil` as well:
|
|
250
250
|
class Foo
|
251
251
|
include Eigindir
|
252
252
|
|
253
|
-
attribute :baz, coerce:
|
253
|
+
attribute :baz, coerce: ->(value) { value.to_s }, strict: true
|
254
254
|
end
|
255
255
|
|
256
256
|
foo = Foo.new
|
data/lib/eigindir/api.rb
CHANGED
@@ -54,15 +54,13 @@ module Eigindir
|
|
54
54
|
|
55
55
|
def __readers
|
56
56
|
@__readers ||= begin
|
57
|
-
|
58
|
-
default || []
|
57
|
+
(superclass.send(:__readers).dup if superclass.is_a? Eigindir::API).to_a
|
59
58
|
end
|
60
59
|
end
|
61
60
|
|
62
61
|
def __writers
|
63
62
|
@__writers ||= begin
|
64
|
-
|
65
|
-
default || []
|
63
|
+
(superclass.send(:__writers).dup if superclass.is_a? Eigindir::API).to_a
|
66
64
|
end
|
67
65
|
end
|
68
66
|
|
data/lib/eigindir/version.rb
CHANGED
data/spec/tests/eigindir_spec.rb
CHANGED
@@ -55,8 +55,13 @@ describe Eigindir do
|
|
55
55
|
it "returns attributes defined in superclass" do
|
56
56
|
parent = Class.new { include Eigindir }
|
57
57
|
parent.attribute :foo, coerce: ->(_) { 1 }, strict: true
|
58
|
-
|
59
|
-
|
58
|
+
klass = Class.new(parent) { attribute :bar }
|
59
|
+
|
60
|
+
pater = parent.new
|
61
|
+
child = klass.new
|
62
|
+
|
63
|
+
expect(pater.attributes).to eq(foo: 1)
|
64
|
+
expect(child.attributes).to eq(foo: 1, bar: nil)
|
60
65
|
end
|
61
66
|
|
62
67
|
end # describe #attributes
|