y_support 2.0.5 → 2.0.6
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/lib/y_support/name_magic.rb +16 -19
- data/lib/y_support/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: f967a550973926b2ab9ad6d5df847b29bad6a27d
|
4
|
+
data.tar.gz: 95ad37737fff575a53db65f9da4ed829d58f8ccb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce8b98cfbc46430bde6d324045772e34ded7791a4fcb8470b71ebd9f01825bcc48f68afcf0670f28b70c728201b48acef96ac72cb4f2bbee8031f9da2200880d
|
7
|
+
data.tar.gz: 6709e08ebd27dcdd0202239ab4a00197bd2978353b7b6f1b2894dd6832ac18ac8288d4a7a5ceb6e0787561961d8462b4ecd316150ddbee7c9927f1af93af97ed
|
data/lib/y_support/name_magic.rb
CHANGED
@@ -135,7 +135,7 @@ module NameMagic
|
|
135
135
|
#
|
136
136
|
def instances
|
137
137
|
const_magic
|
138
|
-
__instances__.keys
|
138
|
+
__instances__.keys.select { |i| i.kind_of? self }
|
139
139
|
end
|
140
140
|
|
141
141
|
# Presents an array of all the instance names (disregarding anonymous
|
@@ -148,14 +148,14 @@ module NameMagic
|
|
148
148
|
# Presents class-owned @instances without const_magic.
|
149
149
|
#
|
150
150
|
def __instances__
|
151
|
-
namespace.instance_variable_get( :@instances )
|
151
|
+
namespace.instance_variable_get( :@instances ) ||
|
152
152
|
namespace.instance_variable_set( :@instances, {} )
|
153
153
|
end
|
154
154
|
|
155
155
|
# Presents class-owned @avid_instances (no const_magic).
|
156
156
|
#
|
157
157
|
def __avid_instances__
|
158
|
-
namespace.instance_variable_get( :@avid_instances )
|
158
|
+
namespace.instance_variable_get( :@avid_instances ) ||
|
159
159
|
namespace.instance_variable_set( :@avid_instances, [] )
|
160
160
|
end
|
161
161
|
|
@@ -167,26 +167,23 @@ module NameMagic
|
|
167
167
|
self
|
168
168
|
end
|
169
169
|
|
170
|
-
# Returns
|
170
|
+
# Returns the instance identified by the argument. NameError is raised, if
|
171
171
|
# the argument does not identify an instance. (It can be an instance name
|
172
|
-
# as string, symbol, or an instance itself, in which case
|
173
|
-
# returned without changes.)
|
172
|
+
# as string, symbol, or an instance itself, in which case, the instance in
|
173
|
+
# question is merely returned without changes.)
|
174
174
|
#
|
175
175
|
def instance arg
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
fail TypeError, "'nil' is not a valid argument type for " +
|
180
|
-
"NameMagic#instance method!" if arg.nil?
|
176
|
+
# In @instances hash, name 'nil' means nameless!
|
177
|
+
msg = "'nil' is not a valid argument type for NameMagic#instance method!"
|
178
|
+
fail TypeError, msg if arg.nil?
|
181
179
|
# if the argument is an actual instance, just return it
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
return r[0]
|
180
|
+
ii = instances
|
181
|
+
return arg if ii.include? arg
|
182
|
+
# otherwise, assume arg is a name
|
183
|
+
begin
|
184
|
+
ii.find { |i| i.name == arg || i.name == arg.to_sym }
|
185
|
+
rescue NoMethodError
|
186
|
+
end or raise NameError, "No instance #{arg} in #{namespace}."
|
190
187
|
end
|
191
188
|
|
192
189
|
|
data/lib/y_support/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: y_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- boris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|