tainbox 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/lib/tainbox/class_methods.rb +1 -1
- data/lib/tainbox/instance_methods.rb +2 -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: f1d90e3036928f02e1e541bb6be2442a2eef11dd
|
4
|
+
data.tar.gz: 8f82d0447b079b1eefd8ecd4770d80ae421a1419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3dd133bcc4b170c2628c14f22338e546b1ce6d150347175997c2894411205943654193e52d7df51d32693300559c9ada285c3c0e6a54839206e16d83a594d31
|
7
|
+
data.tar.gz: ffc7c3348fc39ba1fec0d99f06016e3248ebbce12dacbde5516e194e4c9e7cb9355be11ef0d0c4c566ff3b92f845bb28617374a2ffc6b9af303583eea1db757c
|
data/README.md
CHANGED
@@ -25,6 +25,19 @@ person.attributes = {}
|
|
25
25
|
person.attributes # => { :name => "person_20", :age => 20 }
|
26
26
|
```
|
27
27
|
|
28
|
+
## But what's wrong with Virtus?
|
29
|
+
|
30
|
+
Observe:
|
31
|
+
|
32
|
+
``` ruby
|
33
|
+
class Person
|
34
|
+
include Virtus::Model
|
35
|
+
attribute :age, Integer
|
36
|
+
end
|
37
|
+
|
38
|
+
Person.new(age: 'invalid_integer').age # => "invalid_integer"
|
39
|
+
```
|
40
|
+
|
28
41
|
## Additional features
|
29
42
|
|
30
43
|
### Method overrides
|
@@ -59,7 +72,7 @@ person.attribute_provided?(:age) # => false
|
|
59
72
|
person.attribute_provided?(:name) # => true
|
60
73
|
```
|
61
74
|
|
62
|
-
###
|
75
|
+
### Readonly and writeonly attributes
|
63
76
|
|
64
77
|
Speaks for itself:
|
65
78
|
|
@@ -5,10 +5,10 @@ require_relative 'extensions'
|
|
5
5
|
module Tainbox::InstanceMethods
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
|
-
|
9
|
-
if self.class.tainbox_initialize_suppressed?
|
8
|
+
if self.class.tainbox_initializer_suppressed?
|
10
9
|
super
|
11
10
|
else
|
11
|
+
attributes = (args.length >= 1) ? args.first : {}
|
12
12
|
self.attributes = attributes
|
13
13
|
end
|
14
14
|
end
|
data/lib/tainbox/version.rb
CHANGED