that_object_is_so_basic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +4 -0
- data/lib/toisb/version.rb +1 -1
- data/lib/toisb/wrapper.rb +4 -3
- data/uspec/wrapper_spec.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3240b6bc2376e8bbd65e92e3efe56d316d9f38c914e56aa0a023e4aafce5f9e
|
4
|
+
data.tar.gz: c07e199fd6558461208354792815bfc6dc5ed3b3c4ebb06563259c8064fb851c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 629bd1061c85d0f22d9b77f9f69e86b9c624fee8ad996acba880e335cda66afe5555771914f8f9a56efe43bcea27edbd9a42ab2b519a3ccb12d8da7cb4ee6e58
|
7
|
+
data.tar.gz: 20d2695a437b94d17598ba8687871b9179d708cb16f56ef3738dd61aa279c1c6f5d9e75322606aba72e3f905afc35e9d4f579979798845c6b85f2153ec704a0c
|
data/README.markdown
CHANGED
@@ -3,6 +3,10 @@ That Object is So Basic!
|
|
3
3
|
|
4
4
|
TOISB lets you play with BasicObject and other weird objects in Ruby in style and without breaking (as many) things.
|
5
5
|
|
6
|
+
[![Gem](https://img.shields.io/gem/v/that_object_is_so_basic.svg?style=for-the-badge)](https://rubygems.org/gems/that_object_is_so_basic)
|
7
|
+
[![Travis (.org)](https://img.shields.io/travis/acook/that_object_is_so_basic.svg?style=for-the-badge)](https://travis-ci.org/acook/that_object_is_so_basic)
|
8
|
+
[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/acook/that_object_is_so_basic.svg?style=for-the-badge)](https://codeclimate.com/github/acook/that_object_is_so_basic)
|
9
|
+
|
6
10
|
Usage
|
7
11
|
-----
|
8
12
|
|
data/lib/toisb/version.rb
CHANGED
data/lib/toisb/wrapper.rb
CHANGED
@@ -20,7 +20,7 @@ module TOISB; class Wrapper
|
|
20
20
|
|
21
21
|
# Collects the ancestors of an object
|
22
22
|
def ancestors
|
23
|
-
@ancestors ||=
|
23
|
+
@ancestors ||= singleton.ancestors
|
24
24
|
end
|
25
25
|
|
26
26
|
# Collects only the ancestors which are Classes
|
@@ -30,12 +30,12 @@ module TOISB; class Wrapper
|
|
30
30
|
|
31
31
|
# Returns the class of the object if it isn't already a class
|
32
32
|
def klass
|
33
|
-
@klass ||=
|
33
|
+
@klass ||= singleton.superclass
|
34
34
|
end
|
35
35
|
|
36
36
|
# Returns the superclass of the object
|
37
37
|
def superklass
|
38
|
-
|
38
|
+
klass.superclass
|
39
39
|
end
|
40
40
|
|
41
41
|
# Gets the object ID of an object
|
@@ -50,6 +50,7 @@ module TOISB; class Wrapper
|
|
50
50
|
|
51
51
|
# This is here so you can pass in an arbitrary object
|
52
52
|
def safe_send_to target, method, *args, &block
|
53
|
+
raise NotImplementedError, "Bind functionality wasn't added until Ruby 2.0." if ::RUBY_VERSION < "2.0.0"
|
53
54
|
(Module === target ? Module : Object).instance_method(method).bind(target).call(*args, &block)
|
54
55
|
end
|
55
56
|
|
data/uspec/wrapper_spec.rb
CHANGED
@@ -16,11 +16,12 @@ spec "can get the singleton class of a BasicObject subclass" do
|
|
16
16
|
actual.include?(expected) || actual
|
17
17
|
end
|
18
18
|
|
19
|
+
# FIXME: Is it possible to get this to work on 2.0-2.2?
|
19
20
|
spec "can send common Object methods safely to a BasicObject subclass" do
|
20
21
|
expected = "#<TestObject:"
|
21
22
|
actual = toisb.safe_send :to_s
|
22
23
|
actual.include?(expected) || actual
|
23
|
-
end
|
24
|
+
end unless RUBY_VERSION < "2.3.0"
|
24
25
|
|
25
26
|
spec "can get the class of a BasicObject" do
|
26
27
|
expected = "TestObject"
|