active_object 2.2.1 → 2.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 +34 -0
- data/lib/active_object/object.rb +16 -0
- data/lib/active_object/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec37d1ba7db3451a1f64e3695b8b71d5f3d2cb2
|
4
|
+
data.tar.gz: 8d0eff075433d464db5451bdac6b25e2425d7877
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f03e3165db6a76005dbbcfa4caaed3619861923bfba0fcbc68a5eff82070cc1c94fbb1ed21c8c4c9ce1480aaec879d77a9d3b25d01ea9e9923881c2cbd0b5d5
|
7
|
+
data.tar.gz: 4fa196f3b43d05ee6f99fd768caefdde87f8ee05bf8baeacd01f34ef515836b95f7283e7897c213f6cdb57d375ac0b7ee7f5c5ab16ebdd571366710b9ca17900
|
data/README.md
CHANGED
@@ -1115,6 +1115,23 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1115
1115
|
"Awesome Sting".blank? #=> false
|
1116
1116
|
```
|
1117
1117
|
|
1118
|
+
####False:####
|
1119
|
+
`false?` determines if an object is false.
|
1120
|
+
|
1121
|
+
```ruby
|
1122
|
+
false.false? #=> true
|
1123
|
+
true.false? #=> false
|
1124
|
+
```
|
1125
|
+
|
1126
|
+
####Falsey:####
|
1127
|
+
`falsey?` determines if an object is false, nil, or 0.
|
1128
|
+
|
1129
|
+
```ruby
|
1130
|
+
false.falsey? #=> true
|
1131
|
+
true.falsey? #=> false
|
1132
|
+
0.falsey? #=> true
|
1133
|
+
```
|
1134
|
+
|
1118
1135
|
####Numeric:####
|
1119
1136
|
`numeric?` determines if an object's string value is numeric.
|
1120
1137
|
|
@@ -1141,6 +1158,23 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1141
1158
|
"".present? #=> false
|
1142
1159
|
```
|
1143
1160
|
|
1161
|
+
####True:####
|
1162
|
+
`true?` determines if an object is true.
|
1163
|
+
|
1164
|
+
```ruby
|
1165
|
+
true.true? #=> true
|
1166
|
+
false.true? #=> false
|
1167
|
+
```
|
1168
|
+
|
1169
|
+
####Truthy:####
|
1170
|
+
`truthy?` determines if an object is true or 1.
|
1171
|
+
|
1172
|
+
```ruby
|
1173
|
+
true.truthy? #=> true
|
1174
|
+
false.truthy? #=> false
|
1175
|
+
1.truthy? #=> true
|
1176
|
+
```
|
1177
|
+
|
1144
1178
|
####Try:####
|
1145
1179
|
`try` and `try!` invokes the public method whose name goes as first argument just like public_send does, except that if the receiver does not respond to it the call returns nil rather than raising an exception. `Rails Safe`
|
1146
1180
|
|
data/lib/active_object/object.rb
CHANGED
@@ -8,6 +8,14 @@ class Object
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
+
def false?
|
12
|
+
self == false
|
13
|
+
end
|
14
|
+
|
15
|
+
def falsey?
|
16
|
+
[false, nil, 0].include?(self)
|
17
|
+
end
|
18
|
+
|
11
19
|
def numeric?
|
12
20
|
!to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/).nil?
|
13
21
|
end
|
@@ -22,6 +30,14 @@ class Object
|
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
33
|
+
def true?
|
34
|
+
self == true
|
35
|
+
end
|
36
|
+
|
37
|
+
def truthy?
|
38
|
+
!falsey?
|
39
|
+
end
|
40
|
+
|
25
41
|
unless defined?(Rails)
|
26
42
|
def try(*a, &b)
|
27
43
|
try!(*a, &b) if a.empty? || respond_to?(a.first)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|