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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86e57352d477cc93b8cbd9b46ee175a34d5afc55
4
- data.tar.gz: fcefa4d63aa5f4ecaa51ced21139c6eaf893229f
3
+ metadata.gz: be835e42320b77c3472c9daa12b24e40ae031df6
4
+ data.tar.gz: 92e0ba8cbdf56b9d1348c5e7fbd5e437afc94830
5
5
  SHA512:
6
- metadata.gz: 6c368579ee3cc6ca1a05be5011b51df3619364afa300fa0b9f877beec6ecac4952fd23608138993fb3b196d74937384e0620e3f0ae7c69d8a086654883f63e40
7
- data.tar.gz: 2495c3dc7209c5bfbd1a613f8024d691a726ecd96cb704a120f9b5997a4c6eceeb227cc0c346cafbc6c76a954efd49f5971996455d1d32d54929d2f3082aec34
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 :-)
@@ -1,3 +1,3 @@
1
1
  module MetaInstance
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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 self.respond_to?("#{METHOD_BACKUP_KEY}#{name}")
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 metaclass
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
- meta_eval {
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
- # The hidden singleton lurks behind everyone
49
- def metaclass
50
- class << self
51
- self
52
- end
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
- metaclass.instance_eval(&block)
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.1
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.1
111
+ summary: MetaInstance-1.0.2
112
112
  test_files:
113
113
  - spec/meta_instance_spec.rb
114
114
  - spec/spec_helper.rb