tainbox 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f97ba89e290c39aa627d72acdd087f15d8425535
4
- data.tar.gz: 4187cef87c10dea2fc9be5cf80c26f0bc936ff40
3
+ metadata.gz: bddb6130c428ff13481ff1758fbf20a44caf5eef
4
+ data.tar.gz: e785b9801259f7a6f02520566fe7245d71b8ee41
5
5
  SHA512:
6
- metadata.gz: d445dad53f0615cd342ec4adb1bd80885328e68308d933f13c7993066fd168255d7703c4540354b02f698051082ff2a665649d36cfeea4c0062ca1b8aee7bc57
7
- data.tar.gz: 103da0ff13be9e547dfa04f40a63d8507de78bbcde8e0a3a63e43273a265b24f6e233e555ba68b00fcd24db379866e0b8bf80039fa44d4c09dd3c2b55c527404
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(attributes = {})
8
- self.attributes = attributes
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
@@ -1,3 +1,3 @@
1
1
  module Tainbox
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tainbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Gubitskiy