mobj 2.1.0 → 2.2.0
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.
- data/lib/mobj.rb +10 -10
- metadata +1 -1
data/lib/mobj.rb
CHANGED
@@ -5,10 +5,10 @@ module Mobj
|
|
5
5
|
klass = class << self; self end
|
6
6
|
klass.superclass
|
7
7
|
end
|
8
|
-
def null!() self end
|
9
|
-
def nil!() self end
|
8
|
+
def null!(*args) self end
|
9
|
+
def nil!(*args) self end
|
10
10
|
def itself() self end
|
11
|
-
def alter(*args, &block)
|
11
|
+
def alter(*args, &block) instance_exec(*args, &block) || self end
|
12
12
|
alias_method :o!, :alter
|
13
13
|
|
14
14
|
end
|
@@ -57,13 +57,13 @@ module Mobj
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def try?(default=nil)
|
61
|
-
Forwarder.new do |name, *args, &
|
60
|
+
def try?(default=nil, &block)
|
61
|
+
Forwarder.new do |name, *args, &fblock|
|
62
62
|
if methods(true).include?(name)
|
63
|
-
__send__(name, *args, &
|
63
|
+
__send__(name, *args, &fblock)
|
64
64
|
elsif is_a?(Hash) && ki?(name)
|
65
65
|
self[name]
|
66
|
-
end || default || nil.null!
|
66
|
+
end || (block ? instance_exec(*[*default], &block) : default) || nil.null!
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -109,15 +109,15 @@ module Mobj
|
|
109
109
|
file != __FILE__ || !(MOBJ_NULL_REGION_BEGIN..MOBJ_NULL_REGION_END).cover?(line.to_i)
|
110
110
|
end
|
111
111
|
end
|
112
|
-
def null?()
|
112
|
+
def null?(*args)
|
113
113
|
@@null ||= nil
|
114
114
|
@@null && @@null == __mobj__caller
|
115
115
|
end
|
116
|
-
def null!()
|
116
|
+
def null!(*args)
|
117
117
|
@@null = __mobj__caller
|
118
118
|
self
|
119
119
|
end
|
120
|
-
def nil!
|
120
|
+
def nil!(*args)
|
121
121
|
@@null = nil
|
122
122
|
self
|
123
123
|
end
|