identifies_as 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -10,3 +10,7 @@ Added support for subclassing and module inclusion.
10
10
  Added Module-level support for :<, :>, :<=, :>=, :<==>.
11
11
  Updates for support to stop identification when an ancestor identifies (either actually or by way of IdentifiesAs).
12
12
  Fix for Module (now Module includes IdentifiesAs::ClassInstance).
13
+
14
+ == 6/13/2012
15
+
16
+ Fix for ClassInstance - now defined directly in Module since it seems Module methods are defined in the class not in a module interface, which means we can't insert methods before and call super.
data/lib/identifies_as.rb CHANGED
@@ -1,30 +1,247 @@
1
1
 
2
- require 'module-cluster'
3
-
4
2
  module ::IdentifiesAs
5
3
  end
6
4
 
7
- basepath = 'identifies_as/IdentifiesAs'
5
+ # source file requires
6
+ require_relative './requires.rb'
7
+
8
+ module ::IdentifiesAs
8
9
 
9
- files = [
10
+ @identities = { }
11
+ @instance_identities = { }
10
12
 
11
- 'ActuallyIsA',
13
+ @do_not_identify_as = { }
14
+ @instances_do_not_identify_as = { }
12
15
 
13
- 'ClassInstance',
14
- 'ObjectInstance'
16
+ ################################
17
+ # self.object_identifies_as! #
18
+ ################################
15
19
 
16
- ]
20
+ def self.object_identifies_as!( object, *objects )
17
21
 
18
- files.each do |this_file|
19
- require_relative( File.join( basepath, this_file ) + '.rb' )
20
- end
22
+ object_id = object.__id__
23
+
24
+ unless identifies_as_hash = @identities[ object_id ]
25
+ identifies_as_hash = { }
26
+ @identities[ object_id ] = identifies_as_hash
27
+ end
28
+
29
+ objects.each do |this_object|
30
+ identifies_as_hash[ this_object ] = true
31
+ end
32
+
33
+ if do_not_identify_as_hash = @do_not_identify_as[ object_id ]
34
+ objects.each do |this_object|
35
+ do_not_identify_as_hash.delete( this_object )
36
+ end
37
+ end
38
+
39
+ return identifies_as_hash
40
+
41
+ end
21
42
 
22
- require_relative( basepath + '.rb' )
43
+ ########################################
44
+ # self.object_instances_identify_as! #
45
+ ########################################
46
+
47
+ def self.object_instances_identify_as!( object_class, *objects )
23
48
 
24
- class ::Object
25
- include ::IdentifiesAs
49
+ unless identifies_as_hash = @instance_identities[ object_class ]
50
+ identifies_as_hash = { }
51
+ @instance_identities[ object_class ] = identifies_as_hash
52
+ end
53
+
54
+ objects.each do |this_object|
55
+ identifies_as_hash[ this_object ] = true
56
+ end
57
+
58
+ if do_not_identify_as_hash = @instances_do_not_identify_as[ object_class ]
59
+ objects.each do |this_object|
60
+ do_not_identify_as_hash.delete( object_class )
61
+ end
62
+ end
63
+
64
+ return identifies_as_hash
65
+
66
+ end
67
+
68
+ ################################
69
+ # self.object_identifies_as? #
70
+ ################################
71
+
72
+ def self.object_identifies_as?( object, other_object_type )
73
+
74
+ object_identifies = object_instance_identifies_as?( object, other_object_type )
75
+
76
+ # If we got nil that means we were told to stop looking.
77
+ unless object_identifies or object_identifies.nil?
78
+ object_identifies = object_instances_identify_as?( object.class, other_object_type )
79
+ end
80
+
81
+ if object_identifies.nil?
82
+ object_identifies = false
83
+ end
84
+
85
+ return object_identifies
86
+
87
+ end
88
+
89
+ #########################################
90
+ # self.object_instance_identifies_as? #
91
+ #########################################
92
+
93
+ def self.object_instance_identifies_as?( object, other_object_type )
94
+
95
+ object_identifies = false
96
+
97
+ object_ancestor_chain = nil
98
+
99
+ if object.actually_is_a?( ::Module )
100
+ object_ancestor_chain = object.ancestors.dup
101
+ else
102
+ object_ancestor_chain = [ object ]
103
+ if object.actually_is_a?( ::Symbol ) or object.actually_is_a?( ::Fixnum )
104
+ object_ancestor_chain.concat( object.class.ancestors )
105
+ else
106
+ object_ancestor_chain.concat( class << object ; ancestors ; end )
107
+ end
108
+ end
109
+
110
+ object_ancestor_chain.each do |this_ancestor|
111
+
112
+ this_ancestor_id = this_ancestor.__id__
113
+
114
+ if do_not_identify_as_hash = @do_not_identify_as[ this_ancestor_id ] and
115
+ do_not_identify_as_hash.has_key?( other_object_type )
116
+ object_identifies = nil
117
+ break
118
+ elsif identifies_as_hash = @identities[ this_ancestor_id ]
119
+ break if object_identifies = identifies_as_hash.has_key?( other_object_type )
120
+ end
121
+
122
+ end
123
+
124
+ return object_identifies
125
+
126
+ end
127
+
128
+ ########################################
129
+ # self.object_instances_identify_as? #
130
+ ########################################
131
+
132
+ def self.object_instances_identify_as?( object_class, other_object_type )
133
+
134
+ object_identifies = false
135
+ object_class.ancestors.each do |this_ancestor|
136
+ if do_not_identify_as_hash = @instances_do_not_identify_as[ this_ancestor ] and
137
+ do_not_identify_as_hash.has_key?( other_object_type )
138
+ object_identifies = nil
139
+ break
140
+ elsif identifies_as_hash = @instance_identities[ this_ancestor ]
141
+ object_identifies = identifies_as_hash.has_key?( other_object_type )
142
+ end
143
+
144
+ end
145
+
146
+ return object_identifies
147
+
148
+ end
149
+
150
+ ############################
151
+ # self.object_identities #
152
+ ############################
153
+
154
+ def self.object_identities( object )
155
+
156
+ return object_identities_hash( object ).keys
157
+
158
+ end
159
+
160
+ #####################################
161
+ # self.object_instance_identities #
162
+ #####################################
163
+
164
+ def self.object_instance_identities( object_class )
165
+
166
+ return object_instance_identities_hash( object_class ).keys
167
+
168
+ end
169
+
170
+ #################################
171
+ # self.object_identities_hash #
172
+ #################################
173
+
174
+ def self.object_identities_hash( object )
175
+
176
+ return @identities[ object.__id__ ]
177
+
178
+ end
179
+
180
+ ##########################################
181
+ # self.object_instance_identities_hash #
182
+ ##########################################
183
+
184
+ def self.object_instance_identities_hash( object_class )
185
+
186
+ return @instance_identities[ object_class ]
187
+
188
+ end
189
+
190
+ ######################################
191
+ # self.stop_object_identifying_as! #
192
+ ######################################
193
+
194
+ def self.stop_object_identifying_as!( object, *objects )
195
+
196
+ object_id = object.__id__
197
+
198
+ if identifies_as_hash = @identities[ object_id ]
199
+ objects.each do |this_object|
200
+ identifies_as_hash.delete( this_object )
201
+ end
202
+ end
203
+
204
+ unless do_not_identify_as_hash = @do_not_identify_as[ object_id ]
205
+ do_not_identify_as_hash = { }
206
+ @do_not_identify_as[ object_id ] = do_not_identify_as_hash
207
+ end
208
+
209
+ objects.each do |this_object|
210
+ do_not_identify_as_hash[ this_object ] = true
211
+ end
212
+
213
+ return identifies_as_hash
214
+
215
+ end
216
+
217
+ ################################################
218
+ # self.stop_object_instances_identifying_as! #
219
+ ################################################
220
+
221
+ def self.stop_object_instances_identifying_as!( object_class, *objects )
222
+
223
+ if identifies_as_hash = @instance_identities[ object_class ]
224
+ object_identifies = identifies_as_hash.has_key?( object_class )
225
+ objects.each do |this_object|
226
+ object_identifies.delete( this_object )
227
+ end
228
+ end
229
+
230
+ unless do_not_identify_as_hash = @instances_do_not_identify_as[ object_class ]
231
+ do_not_identify_as_hash = { }
232
+ @instances_do_not_identify_as[ object_class ] = do_not_identify_as_hash
233
+ end
234
+
235
+ objects.each do |this_object|
236
+ do_not_identify_as_hash[ this_object ] = true
237
+ end
238
+
239
+ return identifies_as_hash
240
+
241
+ end
242
+
26
243
  end
27
244
 
28
- class ::Module
29
- include ::IdentifiesAs::ClassInstance
245
+ class ::Object
246
+ include ::IdentifiesAs
30
247
  end
@@ -61,7 +61,7 @@ module ::IdentifiesAs::ObjectInstance
61
61
  def is_a?( object )
62
62
 
63
63
  is_type = false
64
-
64
+
65
65
  if identifies_as?( object )
66
66
  is_type = true
67
67
  else
@@ -1,5 +1,5 @@
1
1
 
2
- module ::IdentifiesAs::ClassInstance
2
+ class ::Module
3
3
 
4
4
  ############################
5
5
  # instances_identify_as! #
@@ -57,14 +57,16 @@ module ::IdentifiesAs::ClassInstance
57
57
  # === #
58
58
  #########
59
59
 
60
+ alias_method :case_compare, :===
61
+
60
62
  def ===( object )
61
63
 
62
64
  is_equal = false
63
65
 
64
- if ::IdentifiesAs.object_identifies_as?( object, self )
66
+ if ::IdentifiesAs.respond_to?( :object_identifies_as? ) and ::IdentifiesAs.object_identifies_as?( object, self )
65
67
  is_equal = true
66
68
  else
67
- is_equal = super
69
+ is_equal = case_compare( object )
68
70
  end
69
71
 
70
72
  return is_equal
@@ -75,9 +77,11 @@ module ::IdentifiesAs::ClassInstance
75
77
  # < #
76
78
  #######
77
79
 
80
+ alias_method :less_than, :<
81
+
78
82
  def <( object )
79
83
 
80
- is_less_than = super
84
+ is_less_than = less_than( object )
81
85
 
82
86
  if is_less_than.nil?
83
87
  # a class is < another class if it has the other class as one of its ancestors
@@ -94,9 +98,11 @@ module ::IdentifiesAs::ClassInstance
94
98
  # > #
95
99
  #######
96
100
 
101
+ alias_method :greater_than, :>
102
+
97
103
  def >( object )
98
104
 
99
- is_greater_than = super
105
+ is_greater_than = greater_than( object )
100
106
 
101
107
  if is_greater_than.nil?
102
108
  # a class is > another class if the other class has it as one of its ancestors
@@ -118,9 +124,11 @@ module ::IdentifiesAs::ClassInstance
118
124
  # <= #
119
125
  ########
120
126
 
127
+ alias_method :less_than_or_equal_to, :<=
128
+
121
129
  def <=( object )
122
130
 
123
- is_less_than_or_equal_to = super
131
+ is_less_than_or_equal_to = less_than_or_equal_to( object )
124
132
 
125
133
  if is_less_than_or_equal_to.nil?
126
134
  # a class is < another class if it has the other class as one of its ancestors
@@ -137,9 +145,11 @@ module ::IdentifiesAs::ClassInstance
137
145
  # >= #
138
146
  ########
139
147
 
148
+ alias_method :greater_than_or_equal_to, :>=
149
+
140
150
  def >=( object )
141
151
 
142
- is_greater_than_or_equal_to = super
152
+ is_greater_than_or_equal_to = greater_than_or_equal_to( object )
143
153
 
144
154
  if is_greater_than_or_equal_to.nil?
145
155
  # a class is < another class if it has the other class as one of its ancestors
@@ -161,6 +171,8 @@ module ::IdentifiesAs::ClassInstance
161
171
  # <=> #
162
172
  #########
163
173
 
174
+ alias_method :compare, :<=>
175
+
164
176
  def <=>( object )
165
177
 
166
178
  less_than_equal_to_greater_than = nil
data/lib/namespaces.rb ADDED
File without changes
data/lib/requires.rb ADDED
@@ -0,0 +1,25 @@
1
+
2
+ require 'module-cluster'
3
+
4
+ module ::IdentifiesAs
5
+ end
6
+
7
+ basepath = ''
8
+
9
+ files = [
10
+
11
+ 'module',
12
+
13
+ 'identifies_as/actually_is_a',
14
+
15
+ 'identifies_as/object_instance'
16
+
17
+ ]
18
+
19
+ files.each do |this_file|
20
+ require_relative( File.join( this_file ) + '.rb' )
21
+ end
22
+
23
+ class ::Object
24
+ include ::IdentifiesAs::ObjectInstance
25
+ end
@@ -18,7 +18,6 @@ describe ::IdentifiesAs do
18
18
  it 'lets an object pretend it is another object' do
19
19
 
20
20
  instance = Object.new
21
- instance.extend( IdentifiesAs )
22
21
 
23
22
  instance.identifies_as!( Array )
24
23
  instance.identifies_as?( Array ).should == true
@@ -50,12 +49,15 @@ describe ::IdentifiesAs do
50
49
 
51
50
  class SomeOtherClass
52
51
  end
52
+
53
+ module SomeModule
54
+ end
53
55
 
54
56
  class NotAnArray
55
- include IdentifiesAs
56
57
  identifies_as!( Array )
57
58
  instances_identify_as!( Array )
58
59
  identifies_as!( SomeOtherClass )
60
+ instances_identify_as!( SomeModule )
59
61
  end
60
62
  class AlsoNotAnArray < NotAnArray
61
63
  end
@@ -91,11 +93,17 @@ describe ::IdentifiesAs do
91
93
  not_an_array_instance.identifies_as?( Array ).should == true
92
94
  not_an_array_instance.is_a?( Array ).should == true
93
95
  ( Array === not_an_array_instance ).should == true
96
+ not_an_array_instance.identifies_as?( SomeModule ).should == true
97
+ not_an_array_instance.is_a?( SomeModule ).should == true
98
+ ( SomeModule === not_an_array_instance ).should == true
94
99
 
95
100
  also_not_an_array_instance = AlsoNotAnArray.new
96
101
  also_not_an_array_instance.identifies_as?( Array ).should == true
97
102
  also_not_an_array_instance.is_a?( Array ).should == true
98
103
  ( Array === also_not_an_array_instance ).should == true
104
+ ( SomeModule === also_not_an_array_instance ).should == true
105
+ also_not_an_array_instance.identifies_as?( SomeModule ).should == true
106
+ also_not_an_array_instance.is_a?( SomeModule ).should == true
99
107
 
100
108
  module IncludersActLikeArray
101
109
  include IdentifiesAs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: identifies_as
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-13 00:00:00.000000000 Z
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: module-cluster
@@ -36,14 +36,14 @@ executables: []
36
36
  extensions: []
37
37
  extra_rdoc_files: []
38
38
  files:
39
- - lib/identifies_as/IdentifiesAs/ActuallyIsA.rb
40
- - lib/identifies_as/IdentifiesAs/ClassInstance.rb
41
- - lib/identifies_as/IdentifiesAs/ObjectInstance.rb
42
- - lib/identifies_as/IdentifiesAs.rb
39
+ - lib/identifies_as/actually_is_a.rb
40
+ - lib/identifies_as/object_instance.rb
43
41
  - lib/identifies_as.rb
44
- - spec/IdentifiesAs_spec.rb
42
+ - lib/module.rb
43
+ - lib/namespaces.rb
44
+ - lib/requires.rb
45
+ - spec/identifies_as_spec.rb
45
46
  - README.md
46
- - README.rdoc
47
47
  - CHANGELOG.rdoc
48
48
  homepage: http://rubygems.org/gems/identifies_as
49
49
  licenses: []
data/README.rdoc DELETED
@@ -1,89 +0,0 @@
1
- == Identifies As
2
-
3
- http://rubygems.org/gems/identifies_as
4
-
5
- == Summary
6
-
7
- Identities are interfaces. Sometimes it makes more sense to test an identity than a method- but then you don't want to limit flexibility.
8
-
9
- So why not let objects that claim to implement your interface identify as your object?
10
-
11
- IdentifiesAs permits objects to identify as if they are other types of objects.
12
-
13
- == Description
14
-
15
- Provides IdentifiesAs, which offers :identifies_as!, :instances_identify_as!, :identifies_as?, :instances_identify_as?, :stop_identifying_as!, :stop_instances_identifying_as, :identities, :instance_identities, and overrides :is_a? and :===.
16
-
17
- == Install
18
-
19
- * sudo gem install identifies_as
20
-
21
- == Usage
22
-
23
- * Example One:
24
-
25
- class SomeOtherClass
26
- end
27
-
28
- class NotAnArray
29
- include IdentifiesAs
30
- instances_identify_as!( Array )
31
- identifies_as!( SomeOtherClass )
32
- end
33
-
34
- NotAnArray.is_a?( SomeOtherClass )
35
- # => true
36
-
37
- instance = NotAnArray.new
38
-
39
- instance.identifies_as?( Array )
40
- # => true
41
-
42
- instance.is_a?( Array )
43
- # => true
44
-
45
- Array === instance
46
- # => true
47
-
48
- * Example Two:
49
-
50
- instance = Object.new
51
-
52
- instance.extend( IdentifiesAs )
53
-
54
- instance.identifies_as!( Array )
55
-
56
- instance.identifies_as?( Array )
57
- # => true
58
-
59
- instance.is_a?( Array )
60
- # => true
61
-
62
- Array === instance
63
- # => true
64
-
65
-
66
- == License
67
-
68
- (The MIT License)
69
-
70
- Copyright (c) Asher
71
-
72
- Permission is hereby granted, free of charge, to any person obtaining
73
- a copy of this software and associated documentation files (the
74
- 'Software'), to deal in the Software without restriction, including
75
- without limitation the rights to use, copy, modify, merge, publish,
76
- distribute, sublicense, and/or sell copies of the Software, and to
77
- permit persons to whom the Software is furnished to do so, subject to
78
- the following conditions:
79
-
80
- The above copyright notice and this permission notice shall be
81
- included in all copies or substantial portions of the Software.
82
-
83
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
84
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
85
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
86
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
87
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
88
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
89
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,242 +0,0 @@
1
-
2
- module ::IdentifiesAs
3
-
4
- extend ::ModuleCluster::Define::Cluster
5
-
6
- include self::ObjectInstance
7
- include_also_extends( self::ClassInstance )
8
-
9
- @identities = { }
10
- @instance_identities = { }
11
-
12
- @do_not_identify_as = { }
13
- @instances_do_not_identify_as = { }
14
-
15
- ################################
16
- # self.object_identifies_as! #
17
- ################################
18
-
19
- def self.object_identifies_as!( object, *objects )
20
-
21
- object_id = object.__id__
22
-
23
- unless identifies_as_hash = @identities[ object_id ]
24
- identifies_as_hash = { }
25
- @identities[ object_id ] = identifies_as_hash
26
- end
27
-
28
- objects.each do |this_object|
29
- identifies_as_hash[ this_object ] = true
30
- end
31
-
32
- if do_not_identify_as_hash = @do_not_identify_as[ object_id ]
33
- objects.each do |this_object|
34
- do_not_identify_as_hash.delete( this_object )
35
- end
36
- end
37
-
38
- return identifies_as_hash
39
-
40
- end
41
-
42
- ########################################
43
- # self.object_instances_identify_as! #
44
- ########################################
45
-
46
- def self.object_instances_identify_as!( object_class, *objects )
47
-
48
- unless identifies_as_hash = @instance_identities[ object_class ]
49
- identifies_as_hash = { }
50
- @instance_identities[ object_class ] = identifies_as_hash
51
- end
52
-
53
- objects.each do |this_object|
54
- identifies_as_hash[ this_object ] = true
55
- end
56
-
57
- if do_not_identify_as_hash = @instances_do_not_identify_as[ object_class ]
58
- objects.each do |this_object|
59
- do_not_identify_as_hash.delete( object_class )
60
- end
61
- end
62
-
63
- return identifies_as_hash
64
-
65
- end
66
-
67
- ################################
68
- # self.object_identifies_as? #
69
- ################################
70
-
71
- def self.object_identifies_as?( object, other_object_type )
72
-
73
- object_identifies = object_instance_identifies_as?( object, other_object_type )
74
-
75
- # If we got nil that means we were told to stop looking.
76
- unless object_identifies or object_identifies.nil?
77
- object_identifies = object_instances_identify_as?( object.class, other_object_type )
78
- end
79
-
80
- if object_identifies.nil?
81
- object_identifies = false
82
- end
83
-
84
- return object_identifies
85
-
86
- end
87
-
88
- #########################################
89
- # self.object_instance_identifies_as? #
90
- #########################################
91
-
92
- def self.object_instance_identifies_as?( object, other_object_type )
93
-
94
- object_identifies = false
95
-
96
- object_ancestor_chain = nil
97
-
98
- if object.actually_is_a?( ::Module )
99
- object_ancestor_chain = object.ancestors.dup
100
- else
101
- object_ancestor_chain = [ object ]
102
- if object.actually_is_a?( ::Symbol ) or object.actually_is_a?( ::Fixnum )
103
- object_ancestor_chain.concat( object.class.ancestors )
104
- else
105
- object_ancestor_chain.concat( class << object ; ancestors ; end )
106
- end
107
- end
108
-
109
- object_ancestor_chain.each do |this_ancestor|
110
-
111
- this_ancestor_id = this_ancestor.__id__
112
-
113
- if do_not_identify_as_hash = @do_not_identify_as[ this_ancestor_id ] and
114
- do_not_identify_as_hash.has_key?( other_object_type )
115
- object_identifies = nil
116
- break
117
- elsif identifies_as_hash = @identities[ this_ancestor_id ]
118
- break if object_identifies = identifies_as_hash.has_key?( other_object_type )
119
- end
120
-
121
- end
122
-
123
- return object_identifies
124
-
125
- end
126
-
127
- ########################################
128
- # self.object_instances_identify_as? #
129
- ########################################
130
-
131
- def self.object_instances_identify_as?( object_class, other_object_type )
132
-
133
- object_identifies = false
134
- object_class.ancestors.each do |this_ancestor|
135
- if do_not_identify_as_hash = @instances_do_not_identify_as[ this_ancestor ] and
136
- do_not_identify_as_hash.has_key?( other_object_type )
137
- object_identifies = nil
138
- break
139
- elsif identifies_as_hash = @instance_identities[ this_ancestor ]
140
- object_identifies = identifies_as_hash.has_key?( other_object_type )
141
- end
142
-
143
- end
144
-
145
- return object_identifies
146
-
147
- end
148
-
149
- ############################
150
- # self.object_identities #
151
- ############################
152
-
153
- def self.object_identities( object )
154
-
155
- return object_identities_hash( object ).keys
156
-
157
- end
158
-
159
- #####################################
160
- # self.object_instance_identities #
161
- #####################################
162
-
163
- def self.object_instance_identities( object_class )
164
-
165
- return object_instance_identities_hash( object_class ).keys
166
-
167
- end
168
-
169
- #################################
170
- # self.object_identities_hash #
171
- #################################
172
-
173
- def self.object_identities_hash( object )
174
-
175
- return @identities[ object.__id__ ]
176
-
177
- end
178
-
179
- ##########################################
180
- # self.object_instance_identities_hash #
181
- ##########################################
182
-
183
- def self.object_instance_identities_hash( object_class )
184
-
185
- return @instance_identities[ object_class ]
186
-
187
- end
188
-
189
- ######################################
190
- # self.stop_object_identifying_as! #
191
- ######################################
192
-
193
- def self.stop_object_identifying_as!( object, *objects )
194
-
195
- object_id = object.__id__
196
-
197
- if identifies_as_hash = @identities[ object_id ]
198
- objects.each do |this_object|
199
- identifies_as_hash.delete( this_object )
200
- end
201
- end
202
-
203
- unless do_not_identify_as_hash = @do_not_identify_as[ object_id ]
204
- do_not_identify_as_hash = { }
205
- @do_not_identify_as[ object_id ] = do_not_identify_as_hash
206
- end
207
-
208
- objects.each do |this_object|
209
- do_not_identify_as_hash[ this_object ] = true
210
- end
211
-
212
- return identifies_as_hash
213
-
214
- end
215
-
216
- ################################################
217
- # self.stop_object_instances_identifying_as! #
218
- ################################################
219
-
220
- def self.stop_object_instances_identifying_as!( object_class, *objects )
221
-
222
- if identifies_as_hash = @instance_identities[ object_class ]
223
- object_identifies = identifies_as_hash.has_key?( object_class )
224
- objects.each do |this_object|
225
- object_identifies.delete( this_object )
226
- end
227
- end
228
-
229
- unless do_not_identify_as_hash = @instances_do_not_identify_as[ object_class ]
230
- do_not_identify_as_hash = { }
231
- @instances_do_not_identify_as[ object_class ] = do_not_identify_as_hash
232
- end
233
-
234
- objects.each do |this_object|
235
- do_not_identify_as_hash[ this_object ] = true
236
- end
237
-
238
- return identifies_as_hash
239
-
240
- end
241
-
242
- end