y_support 2.0.13 → 2.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d466ad84213f9677a44efdb9d426ae1a24c11688
4
- data.tar.gz: 398a4cbaf4e656dcabd8d87055c5069bcef90275
3
+ metadata.gz: f2417e6453a390dd0001a7add38638b69989f3da
4
+ data.tar.gz: 7c430e880d23c375a741572d7758c0dee3edb19b
5
5
  SHA512:
6
- metadata.gz: ace20c52c5676019cdf9b1633911a134903db65a3bca738e478172ea3d826e4485ab957b4f541fd21e2e0ab924b3ae9336ce5c6922be5ac7252edad5ed893bdf
7
- data.tar.gz: cf26fc0b943d41e39af89f4dbb8025e258733fea47497a6f5be8b030125ccd0efbeb24212dd852833949111fb312f0acb1ea11e7f1e8f19570d9c7a361e6ca0b
6
+ metadata.gz: 7d4ad637111c552d83e59345ee193b6bb15d9dc1d22e2ef31ca2c38500c70370f05a4a27e64c103b7308a315bc1565c4c6955d38373a37e5945f3729b70ff4d4
7
+ data.tar.gz: 6b158e5be9d2652019df69e9b2ee3b3ae0d380283d2d15cfda935c13cf174c6a55370264f9d4eb6006dba3720e8980f20d2670b0f9d7d471258a1cc7470008a1
@@ -158,14 +158,20 @@ module NameMagic
158
158
  self
159
159
  end
160
160
 
161
- # Makes the class use the namespace supplied as the argument. If no argument
162
- # is given, the class/module itself will be made its own namespace. Returns
163
- # self.
161
+ # Makes the class use the namespace supplied as an argument.
164
162
  #
165
- def namespace! namespc=self
163
+ def namespace= namespc
166
164
  namespc.extend ::NameMagic::NamespaceMethods unless namespc == self
167
165
  tap { define_singleton_method :namespace do namespc end }
168
166
  end
167
+
168
+ # Makes the class/module use itself as a namespace. (Useful eg. with
169
+ # parametrized subclassing to tell the subclasses to maintain each their
170
+ # own namespaces.)
171
+ #
172
+ def namespace!
173
+ self.namespace = self
174
+ end
169
175
 
170
176
  # Returns the instance identified by the argument. NameError is raised, if
171
177
  # the argument does not identify an instance. (It can be an instance name
@@ -187,7 +193,6 @@ module NameMagic
187
193
  end or raise NameError, "No instance #{arg} in #{namespace}."
188
194
  end
189
195
 
190
-
191
196
  # The method will search all the modules in the the object space for
192
197
  # receiver class objects assigned to constants, and name these instances
193
198
  # accordingly. Number of the remaining nameless instances is returned.
@@ -1,3 +1,3 @@
1
1
  module YSupport
2
- VERSION = "2.0.13"
2
+ VERSION = "2.0.14"
3
3
  end
@@ -53,5 +53,17 @@ describe NameMagic do
53
53
  @reporter.name_get.must_equal "Name get closure called on UFO"
54
54
  Elaine = @ç.new
55
55
  Elaine.name.must_equal :Elaine
56
+ m = Module.new
57
+ XXX = m
58
+ @ç.namespace = XXX
59
+ @ç.namespace.must_equal m
60
+ Rover = @ç.new
61
+ @ç.const_magic
62
+ XXX::Rover.must_be_kind_of @ç
63
+ @ç.namespace!
64
+ Spot = @ç.new
65
+ @ç.const_magic
66
+ -> { XXX::Spot }.must_raise NameError
67
+ @ç.const_get( :Spot ).must_be_kind_of @ç
56
68
  end
57
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: y_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.13
4
+ version: 2.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - boris