mobj 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ext/hash.rb +2 -2
- data/lib/ext/nil.rb +3 -3
- data/lib/ext/object.rb +6 -6
- data/lib/mobj.rb +9 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2QxNDE3YThlMWI1ZTdkM2FiOGE4YmM0ODBhMDc3ZDA2OTlmZTgyYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDFkOTUwOTg0N2M1M2VlNDkzNjUzMTcxODE5MTNkMzAyNjk3ZTgyZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDRkNTQ3ZmZkNjE1MTc4NjQ2ZmM0MjhkODU5ZmJiMTNjYjY3OGQxZjQ4NGJl
|
10
|
+
MzY1ZDgxZWNkZjRlOWI4OWJmMzg3YThkOWY5OTgxY2YzODIzMzU0ZDkwYTRk
|
11
|
+
YjllODkwZTlhY2ZkNzkxNmEyNTQwNzE5ODliYWE2MDIzODQ1ZGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODE1YWY0NTQ3Y2U5YzAzM2RiZjM3Y2E2OThlZWI4NDRjNTZhOTI0ZGFiMzAw
|
14
|
+
YWI0ZTIwM2RlYTcyMGM0YjE3MzQwY2Y3MjM3YzdmMzE0MTZiYThmOTFjNDQ1
|
15
|
+
YTI2ZGExNTc5ODVmMmYyODczYWVjZTMxNGIyMjQxYWYxYmNiYjk=
|
data/lib/ext/hash.rb
CHANGED
@@ -27,7 +27,7 @@ module Mobj
|
|
27
27
|
|
28
28
|
def symvert(key_converter = :itself, value_converter = key_converter)
|
29
29
|
each.with_object({}) do |(k, v), o|
|
30
|
-
key = if key_converter.
|
30
|
+
key = if key_converter.p?
|
31
31
|
key_converter.call(k, v)
|
32
32
|
elsif k.respond_to?(key_converter.sym)
|
33
33
|
k.__send__(key_converter.sym)
|
@@ -35,7 +35,7 @@ module Mobj
|
|
35
35
|
k
|
36
36
|
end
|
37
37
|
|
38
|
-
value = if value_converter.
|
38
|
+
value = if value_converter.p?
|
39
39
|
value_converter.arity == 1 ? value_converter.call(v) : value_converter.call(k, v)
|
40
40
|
elsif v.respond_to?(value_converter.sym)
|
41
41
|
v.__send__(value_converter.sym)
|
data/lib/ext/nil.rb
CHANGED
@@ -66,10 +66,10 @@ module Mobj
|
|
66
66
|
Forwarder.new do |name, *args, &block|
|
67
67
|
if self.methods(true).include? name
|
68
68
|
self.__send__(name, *args, &block)
|
69
|
-
elsif value.
|
69
|
+
elsif value.p?
|
70
70
|
value.call([name] + args, &block)
|
71
|
-
elsif value.
|
72
|
-
value[name].when.
|
71
|
+
elsif value.h? && value.ki?(name)
|
72
|
+
value[name].when.p?.call(*args, &block)
|
73
73
|
else
|
74
74
|
value
|
75
75
|
end
|
data/lib/ext/object.rb
CHANGED
@@ -57,9 +57,9 @@ module Mobj
|
|
57
57
|
def s!() to_s end
|
58
58
|
def zeno!() z0? ? 1.0 : self end
|
59
59
|
|
60
|
-
def
|
60
|
+
def up!(*args)
|
61
61
|
if a?
|
62
|
-
each { |i| i.
|
62
|
+
each { |i| i.up!(*args) }
|
63
63
|
else
|
64
64
|
if responds_to_all? :assign_attributes, :save
|
65
65
|
args.select(&:h?).each do |arg|
|
@@ -111,10 +111,10 @@ module Mobj
|
|
111
111
|
Forwarder.new do |name, *args, &block|
|
112
112
|
if self.methods(true).include? name ##//use respond to?
|
113
113
|
self.__send__(name, *args, &block)
|
114
|
-
elsif value.
|
114
|
+
elsif value.p?
|
115
115
|
value.call([name] + args, &block)
|
116
|
-
elsif value.
|
117
|
-
value[name].when.
|
116
|
+
elsif value.h? && value.ki?(name)
|
117
|
+
value[name].when.p?.call(*args, &block)
|
118
118
|
else
|
119
119
|
value == :root ? self : value
|
120
120
|
end
|
@@ -125,7 +125,7 @@ module Mobj
|
|
125
125
|
Forwarder.new do |name, *args, &fblock|
|
126
126
|
if methods(true).include?(name)
|
127
127
|
__send__(name, *args, &fblock)
|
128
|
-
elsif
|
128
|
+
elsif h? && ki?(name)
|
129
129
|
self[name]
|
130
130
|
end || (block ? instance_exec(*[*default], &block) : default) || nil.null!
|
131
131
|
end
|
data/lib/mobj.rb
CHANGED
@@ -45,7 +45,7 @@ module Mobj
|
|
45
45
|
path.map { |pth| obj[pth.sym] }
|
46
46
|
elsif path[0] == '*' && obj.respond_to?(path[1..-1].sym)
|
47
47
|
obj.__send__(path[1..-1].sym)
|
48
|
-
elsif obj.respond_to?(:[]) && (obj.
|
48
|
+
elsif obj.respond_to?(:[]) && (obj.h? || path.to_s =~ /[0-9.-]+/)
|
49
49
|
if obj.h?
|
50
50
|
obj[path.sym]
|
51
51
|
else
|
@@ -59,7 +59,7 @@ module Mobj
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def find(obj, match)
|
62
|
-
if obj.
|
62
|
+
if obj.a?
|
63
63
|
obj.map do |child|
|
64
64
|
find(child, match)
|
65
65
|
end
|
@@ -72,7 +72,7 @@ module Mobj
|
|
72
72
|
flat = found.values.flat_map(&:captures).empty?
|
73
73
|
|
74
74
|
found.each.with_object(flat ? [] : {}) { |(key, m), map|
|
75
|
-
if map.
|
75
|
+
if map.a?
|
76
76
|
map << obj[key]
|
77
77
|
else
|
78
78
|
named = m.to_h.invert
|
@@ -104,7 +104,7 @@ module Mobj
|
|
104
104
|
obj.__mobj__parent
|
105
105
|
end
|
106
106
|
when :any
|
107
|
-
if obj.
|
107
|
+
if obj.a?
|
108
108
|
obj.map { |o| walk(o, root) }
|
109
109
|
else
|
110
110
|
@path.return_first { |token| token.walk(obj, root) }
|
@@ -116,7 +116,7 @@ module Mobj
|
|
116
116
|
@path.map { |token| token.walk(obj, root) }
|
117
117
|
when :lookup
|
118
118
|
lookup = @path.walk(obj)
|
119
|
-
if lookup.
|
119
|
+
if lookup.a?
|
120
120
|
lookup.flatten.map { |lu| lu.tokenize.walk(root) }.flatten(1)
|
121
121
|
else
|
122
122
|
lookup.tokenize.walk(root)
|
@@ -128,7 +128,7 @@ module Mobj
|
|
128
128
|
while (path = tree.shift)
|
129
129
|
obj = path.walk(obj)
|
130
130
|
end
|
131
|
-
obj.
|
131
|
+
obj.a? ? obj.flatten : obj
|
132
132
|
end
|
133
133
|
|
134
134
|
val = @options[:indexes] ? val.values_at(*@options[:indexes]) : val
|
@@ -138,13 +138,13 @@ module Mobj
|
|
138
138
|
|
139
139
|
class Circle
|
140
140
|
def self.wrap!(wrapped)
|
141
|
-
return wrapped if wrapped.
|
141
|
+
return wrapped if wrapped.a?(CircleHash) || wrapped.a?(CircleRay)
|
142
142
|
|
143
|
-
if wrapped.
|
143
|
+
if wrapped.a?
|
144
144
|
circle = CircleRay.new
|
145
145
|
wrapped.each_with_index { |item, i| circle[i] = wrap!(item) }
|
146
146
|
circle
|
147
|
-
elsif wrapped.
|
147
|
+
elsif wrapped.h?
|
148
148
|
circle = CircleHash.new
|
149
149
|
wrapped.each_pair { |key, val| circle[key] = wrap!(val) }
|
150
150
|
circle
|