is_a 0.0.2 → 0.0.3
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/README.md +21 -2
- data/lib/is_a.rb +12 -0
- data/lib/is_a/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# IsA
|
2
2
|
|
3
|
-
|
3
|
+
A small library of missing ruby methods for introspection. See Usage.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,26 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
require 'is_a'
|
23
|
+
|
24
|
+
obj = BasicObject.new
|
25
|
+
begin
|
26
|
+
obj.class
|
27
|
+
rescue
|
28
|
+
puts "Yep, BasicObject will not tell you it's class"
|
29
|
+
cls = IsA.class_of(obj)
|
30
|
+
puts "But IsA will. It's #{cls}"
|
31
|
+
end
|
32
|
+
|
33
|
+
IsA.object?(obj) # => false
|
34
|
+
IsA.object?("anything that is derived from Object") # => true
|
35
|
+
|
36
|
+
#Also on 1.9.2 there's no way of getting object_id of BasicObject, here it is:
|
37
|
+
id = IsA.id_of(obj) # or alias ObjectSpace._ref2id(obj)
|
38
|
+
ObjectSpace._id2ref(id) == obj # => true
|
39
|
+
#For 1.9.3 use BasicObject#__id__
|
40
|
+
```
|
22
41
|
|
23
42
|
## Contributing
|
24
43
|
|
data/lib/is_a.rb
CHANGED
data/lib/is_a/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_a
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-11 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70116595563300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70116595563300
|
25
25
|
description: Fear weak references to BasicObject no more
|
26
26
|
email:
|
27
27
|
- vasilyfedoseyev@gmail.com
|