identifies_as 1.1.0 → 1.1.1
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/identifies_as.rb +2 -2
- data/lib/identifies_as/actually_is_a.rb +2 -1
- data/lib/identifies_as/object_instance.rb +16 -6
- data/lib/module.rb +1 -1
- metadata +3 -3
data/lib/identifies_as.rb
CHANGED
@@ -108,11 +108,11 @@ module ::IdentifiesAs
|
|
108
108
|
|
109
109
|
object_ancestor_chain = nil
|
110
110
|
|
111
|
-
if
|
111
|
+
if ::Module.case_compare( object )
|
112
112
|
object_ancestor_chain = object.ancestors.dup
|
113
113
|
else
|
114
114
|
object_ancestor_chain = [ object ]
|
115
|
-
if
|
115
|
+
if ::Symbol.case_compare( object ) or ::Fixnum.case_compare( object )
|
116
116
|
object_ancestor_chain.concat( object.class.ancestors )
|
117
117
|
else
|
118
118
|
object_ancestor_chain.concat( class << object ; ancestors ; end )
|
@@ -8,6 +8,7 @@ module ::IdentifiesAs::ActuallyIsA
|
|
8
8
|
# Alias to the original :is_a? method without IdentifyAs functionality.
|
9
9
|
# @param [Object] objects Other object to test identity against.
|
10
10
|
# @return [true,false] Whether receiver is actually instance of specified object.
|
11
|
-
alias_method :
|
11
|
+
alias_method :__actually_is_a__?, :is_a?
|
12
|
+
alias_method :actually_is_a?, :__actually_is_a__?
|
12
13
|
|
13
14
|
end
|
@@ -10,12 +10,14 @@ module ::IdentifiesAs::ObjectInstance
|
|
10
10
|
# Cause receiver to identify as specified objects.
|
11
11
|
# @param [Array<Object>] objects Other objects self should identify as.
|
12
12
|
# @return [Object] Self.
|
13
|
-
def
|
13
|
+
def __identifies_as__!( *objects )
|
14
14
|
|
15
15
|
return ::IdentifiesAs.object_identifies_as!( self, *objects )
|
16
16
|
|
17
17
|
end
|
18
18
|
|
19
|
+
alias_method :identifies_as!, :__identifies_as__!
|
20
|
+
|
19
21
|
####################
|
20
22
|
# identifies_as? #
|
21
23
|
####################
|
@@ -23,24 +25,28 @@ module ::IdentifiesAs::ObjectInstance
|
|
23
25
|
# Query whether receiver identifies as specified object.
|
24
26
|
# @param [Object] object Object against which identity is being tested.
|
25
27
|
# @return [true,false] Whether receiver identifies as object.
|
26
|
-
def
|
28
|
+
def __identifies_as__?( object )
|
27
29
|
|
28
30
|
return ::IdentifiesAs.object_identifies_as?( self, object )
|
29
31
|
|
30
32
|
end
|
31
33
|
|
34
|
+
alias_method :identifies_as?, :__identifies_as__?
|
35
|
+
|
32
36
|
################
|
33
37
|
# identities #
|
34
38
|
################
|
35
39
|
|
36
40
|
# Identities that receiver identifies as, beyond those which it actually is.
|
37
41
|
# @return [Array<Object>] Identities receiver identifies as.
|
38
|
-
def
|
42
|
+
def __identities__
|
39
43
|
|
40
44
|
return ::IdentifiesAs.object_identities( self )
|
41
45
|
|
42
46
|
end
|
43
47
|
|
48
|
+
alias_method :identities, :__identities__
|
49
|
+
|
44
50
|
##########################
|
45
51
|
# stop_identifying_as! #
|
46
52
|
##########################
|
@@ -48,12 +54,14 @@ module ::IdentifiesAs::ObjectInstance
|
|
48
54
|
# Cause receiver to no longer identify as specified objects.
|
49
55
|
# @param [Array<Object>] objects Other objects receiver should no longer identify as.
|
50
56
|
# @return [Object] Self.
|
51
|
-
def
|
57
|
+
def __stop_identifying_as__!( *objects )
|
52
58
|
|
53
59
|
return ::IdentifiesAs.stop_object_identifying_as!( self, *objects )
|
54
60
|
|
55
61
|
end
|
56
62
|
|
63
|
+
alias_method :stop_identifying_as!, :__stop_identifying_as__!
|
64
|
+
|
57
65
|
###########
|
58
66
|
# is_a? #
|
59
67
|
###########
|
@@ -62,8 +70,8 @@ module ::IdentifiesAs::ObjectInstance
|
|
62
70
|
|
63
71
|
is_type = false
|
64
72
|
|
65
|
-
if
|
66
|
-
|
73
|
+
if __actually_is_a__?( ::IdentifiesAs ) and
|
74
|
+
__identifies_as__?( object )
|
67
75
|
is_type = true
|
68
76
|
else
|
69
77
|
is_type = super
|
@@ -73,4 +81,6 @@ module ::IdentifiesAs::ObjectInstance
|
|
73
81
|
|
74
82
|
end
|
75
83
|
|
84
|
+
alias_method :__is_a__?, :is_a?
|
85
|
+
|
76
86
|
end
|
data/lib/module.rb
CHANGED
@@ -64,7 +64,7 @@ class ::Module
|
|
64
64
|
is_equal = false
|
65
65
|
|
66
66
|
if ::IdentifiesAs.respond_to?( :object_identifies_as? ) and
|
67
|
-
|
67
|
+
::IdentifiesAs.case_compare( object ) and
|
68
68
|
::IdentifiesAs.object_identifies_as?( object, self )
|
69
69
|
is_equal = true
|
70
70
|
else
|
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.1.
|
4
|
+
version: 1.1.1
|
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:
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Identities are interfaces. Sometimes it makes more sense to test an identity
|
15
15
|
than a method- but then you don't want to limit flexibility. So why not let objects
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
50
|
rubyforge_project: identifies_as
|
51
|
-
rubygems_version: 1.8.
|
51
|
+
rubygems_version: 1.8.24
|
52
52
|
signing_key:
|
53
53
|
specification_version: 3
|
54
54
|
summary: Provides IdentifiesAs, which offers :identifies_as!, :identifies_as?, :stop_identifying_as!
|