tainbox 0.2.1 → 0.2.2
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 +11 -0
- data/lib/tainbox/class_methods.rb +10 -0
- data/lib/tainbox/instance_methods.rb +7 -2
- data/lib/tainbox/version.rb +1 -1
- 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: bddb6130c428ff13481ff1758fbf20a44caf5eef
|
4
|
+
data.tar.gz: e785b9801259f7a6f02520566fe7245d71b8ee41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb32461b17e6b0267098db98ae63c302c2135527c0c8da568f806ca528ba4fc9c59c7ff0ed17a8aefcc00824dd1ca1e5c9f2d1254941df84118428645c00268
|
7
|
+
data.tar.gz: 3a20a7f21e5700237c5a65826a7dfcb4149de9a7d5ac1563b79ab33ca789f5c64aa27ffedd62c720275bdbce27af73f2d3f69147107478cc4c6a6e2bbc4e852e
|
data/README.md
CHANGED
@@ -93,3 +93,14 @@ Tainbox.define_converter(MyType) do
|
|
93
93
|
options[:strict] ? MyType.convert!(value) : MyType.convert(value)
|
94
94
|
end
|
95
95
|
```
|
96
|
+
|
97
|
+
### Suppressing tainbox initializer
|
98
|
+
|
99
|
+
If you don't want to pollute your class with tainbox initializer you can do:
|
100
|
+
|
101
|
+
``` ruby
|
102
|
+
class Person
|
103
|
+
include Tainbox
|
104
|
+
suppress_tainbox_initializer!
|
105
|
+
end
|
106
|
+
```
|
@@ -7,8 +7,14 @@ module Tainbox::ClassMethods
|
|
7
7
|
subclass.tainbox_attributes = tainbox_attributes.dup
|
8
8
|
end
|
9
9
|
|
10
|
+
def tainbox_initialize_suppressed?
|
11
|
+
!!tainbox_initializer_suppressed
|
12
|
+
end
|
13
|
+
|
10
14
|
private
|
11
15
|
|
16
|
+
attr_accessor :tainbox_initializer_suppressed
|
17
|
+
|
12
18
|
def attribute(name, type = nil, **args)
|
13
19
|
args = args.dup
|
14
20
|
readonly, writeonly = args.delete(:writeonly), args.delete(:readonly)
|
@@ -16,4 +22,8 @@ module Tainbox::ClassMethods
|
|
16
22
|
definer.define_getter unless writeonly
|
17
23
|
definer.define_setter unless readonly
|
18
24
|
end
|
25
|
+
|
26
|
+
def suppress_tainbox_initializer!
|
27
|
+
self.tainbox_initializer_suppressed = true
|
28
|
+
end
|
19
29
|
end
|
@@ -4,8 +4,13 @@ require_relative 'extensions'
|
|
4
4
|
|
5
5
|
module Tainbox::InstanceMethods
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
|
7
|
+
def initialize(*args)
|
8
|
+
attributes = (args.length >= 1) ? args.first : {}
|
9
|
+
if self.class.tainbox_initialize_suppressed?
|
10
|
+
super
|
11
|
+
else
|
12
|
+
self.attributes = attributes
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
def attributes
|
data/lib/tainbox/version.rb
CHANGED