meta_instance 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/meta_instance/version.rb +1 -1
- data/lib/meta_instance.rb +14 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be835e42320b77c3472c9daa12b24e40ae031df6
|
4
|
+
data.tar.gz: 92e0ba8cbdf56b9d1348c5e7fbd5e437afc94830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7474fb5b29bf649f53e8dfeb759e39afe853aa1ff532d6437d47da825038be142a5fe577996374231c656ad4f13f69e5e46f149341e33b512691d9da5af9be3
|
7
|
+
data.tar.gz: 9e088dd0372b3b1e2d1c01d4203ac842100a2e4ebd748f56e3e5400575035925fd6cfe5c090b60f79231865f86bcb5086682aa5c69f61dfa2890bf8eef132229
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ MetaInstance
|
|
6
6
|
[![Code Climate](https://codeclimate.com/github/NullVoxPopuli/MetaInstance/badges/gpa.svg)](https://codeclimate.com/github/NullVoxPopuli/MetaInstance)
|
7
7
|
[![Test Coverage](https://codeclimate.com/github/NullVoxPopuli/MetaInstance/badges/coverage.svg)](https://codeclimate.com/github/NullVoxPopuli/MetaInstance)
|
8
8
|
[![Dependency Status](https://gemnasium.com/NullVoxPopuli/MetaInstance.svg)](https://gemnasium.com/NullVoxPopuli/MetaInstance)
|
9
|
-
|
9
|
+
[![Security](https://hakiri.io/github/NullVoxPopuli/MetaInstance/master.svg)](https://hakiri.io/github/NullVoxPopuli/MetaInstance/master)
|
10
10
|
|
11
11
|
A few helpers for manipulating methods on an instance of an object.
|
12
12
|
|
@@ -39,4 +39,4 @@ You can do this:
|
|
39
39
|
# => "bar"
|
40
40
|
|
41
41
|
|
42
|
-
See Specs for examples :-)
|
42
|
+
See Specs for examples :-)
|
data/lib/meta_instance.rb
CHANGED
@@ -13,17 +13,20 @@ module MetaInstance
|
|
13
13
|
# backs up and overrides a method.
|
14
14
|
# but don't override if we already have overridden this method
|
15
15
|
def instance_override(name, &block)
|
16
|
-
unless
|
16
|
+
unless respond_to?("#{METHOD_BACKUP_KEY}#{name}")
|
17
17
|
backup_instance_method(name)
|
18
18
|
end
|
19
19
|
instance_define(name, &block)
|
20
20
|
end
|
21
21
|
|
22
|
-
# Adds methods to a
|
22
|
+
# Adds methods to a singletonclass
|
23
|
+
# define_singleton_method(name, &block) is the same as doing
|
24
|
+
#
|
25
|
+
# meta_eval {
|
26
|
+
# define_method(name, &block)
|
27
|
+
# }
|
23
28
|
def instance_define(name, &block)
|
24
|
-
|
25
|
-
define_method(name, &block)
|
26
|
-
}
|
29
|
+
define_singleton_method(name, &block)
|
27
30
|
end
|
28
31
|
|
29
32
|
# backs up a method in case we want to restore it later
|
@@ -45,15 +48,13 @@ module MetaInstance
|
|
45
48
|
|
46
49
|
private
|
47
50
|
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
|
51
|
+
# evals a block inside of a singleton class, aka
|
52
|
+
#
|
53
|
+
# class << self
|
54
|
+
# self
|
55
|
+
# end
|
55
56
|
def meta_eval(&block)
|
56
|
-
|
57
|
+
singleton_class.instance_eval(&block)
|
57
58
|
end
|
58
59
|
|
59
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta_instance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
@@ -108,7 +108,7 @@ rubyforge_project:
|
|
108
108
|
rubygems_version: 2.4.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
|
-
summary: MetaInstance-1.0.
|
111
|
+
summary: MetaInstance-1.0.2
|
112
112
|
test_files:
|
113
113
|
- spec/meta_instance_spec.rb
|
114
114
|
- spec/spec_helper.rb
|