eigenclass 2.0.2 → 2.0.3

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: f734fffd3172d7dc6ba61c300bad51357e850525
4
- data.tar.gz: 8643dc31c8cd81268ba7871a1965c3e14671d2a3
3
+ metadata.gz: 28aeb226955ee8be653bfe54654bfaba09ac50a0
4
+ data.tar.gz: 0a9bba1df21d8a1963ce2ff9f977a2a922e3b228
5
5
  SHA512:
6
- metadata.gz: d1f54bd72ad5a5644826b6740b781c501d04389b144dd32db516701936c6c1caf9c9c87fc23682d8ae78dcd99eb5a2ccaa212df1106df2ab294bb37f8cba6e6e
7
- data.tar.gz: 688a8c74bd8539c1bb4413e8fa6d3d62cf27d7c96de76a99b9d8013c0fd790834be9d09d765127e96555f478094ab325d58416b4aa5ecfa455241e5df80952f7
6
+ metadata.gz: 514da0791c5302694e4117596e2d1226459d80116cdd96ccae4796dc6c7ad8d4d32da85c71f2867205046f73d142db9f91ee5986d6affae4f9bac51ade530252
7
+ data.tar.gz: c17519c4b8daf8f9502ca0f83a839452d712815f3a37fce995c41067d08997c67ea8d65481802df8f672cdca6a2cb8c5b17348fa96ae632f478d975b8f16efa1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eigenclass (2.0.2)
4
+ eigenclass (2.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://www.rubygems.org/
data/README.md CHANGED
@@ -26,8 +26,7 @@ gem install eigenclass
26
26
  Everything in Ruby is an object, including classes.
27
27
 
28
28
  ```ruby
29
- class SomeObject
30
- end
29
+ SomeObject = Class.new
31
30
  ```
32
31
 
33
32
  Every object has an `eigenclass`.
@@ -48,7 +47,7 @@ class Object
48
47
  end
49
48
  ```
50
49
 
51
- Evaluating code within the context of an object's `eigenclass` allows us to do some pretty cool things - like defining class level attributes.
50
+ Evaluating code within an `eigenclass` lets us do some cool things like defining class level attributes.
52
51
 
53
52
  ```ruby
54
53
  SomeObject.eigenclass_eval do
@@ -67,6 +66,8 @@ class SomeObject
67
66
  eattr_reader :example_reader
68
67
  eattr_writer :example_writer
69
68
 
69
+ ealias_method :new_example_accessor, :example_accessor
70
+
70
71
  edefine_method(:example_class_method) do
71
72
  1 + 1
72
73
  end
@@ -75,6 +76,23 @@ end
75
76
  SomeObject.example_class_method #=> 2
76
77
  ```
77
78
 
79
+ When we `extend` modules, we're actually just calling `include` on an object's `eigenclass`.
80
+
81
+ ```ruby
82
+ SomeObject.eigenclass.included_modules #=> [Eigenclass, Kernel]
83
+
84
+ Example = Module.new
85
+ SomeObject.extend(Example)
86
+
87
+ SomeObject.eigenclass.included_modules #=> [Example, Eigenclass, Kernel]
88
+ ```
89
+
90
+ A convenience method for viewing an object's extended modules is available for us as well.
91
+
92
+ ```ruby
93
+ SomeObject.extended_modules #=> [Example, Eigenclass, Kernel]
94
+ ```
95
+
78
96
  Since all objects have an `eigenclass`, we can even define methods for a single _instance_ of a class.
79
97
 
80
98
  ```ruby
@@ -87,15 +105,17 @@ other_object = SomeObject.new
87
105
  other_object.example #=> NoMethodError undefined method `example' for #<SomeObject:0x007fee348dde00>
88
106
  ```
89
107
 
90
- This is pretty incredible! We can hook in and inject behavior into any and all objects - **at runtime**!
108
+ This is pretty incredible! We can hook in and inject behavior into *any and all* objects - **at runtime**!
91
109
 
92
110
  Ruby is like one big plugin framework - with an awesome standard library and amazing community!
93
111
 
94
-
95
112
  ## API
96
113
 
97
114
  [YARD Documentation](http://www.rubydoc.info/github/shuber/eigenclass/master)
98
115
 
116
+ All methods defined by this gem are simple delegators to existing methods on the `eigenclass` object. The links below redirect to each corresponding method in the standard library documentation.
117
+
118
+ * [ealias_method](http://ruby-doc.org/core-1.9.3/Module.html#method-i-alias_method)
99
119
  * [eattr_accessor](http://ruby-doc.org/core-1.9.3/Module.html#method-i-attr_accessor)
100
120
  * [eattr_reader](http://ruby-doc.org/core-1.9.3/Module.html#method-i-attr_reader)
101
121
  * [eattr_writer](http://ruby-doc.org/core-1.9.3/Module.html#method-i-attr_writer)
@@ -103,6 +123,7 @@ Ruby is like one big plugin framework - with an awesome standard library and ama
103
123
  * [eigenclass](http://ruby-doc.org/core-1.9.2/Object.html#method-i-singleton_class)
104
124
  * [eigenclass_eval](http://ruby-doc.org/core-1.9.3/BasicObject.html#method-i-instance_eval)
105
125
  * [eigenclass_exec](http://ruby-doc.org/core-1.9.3/BasicObject.html#method-i-instance_exec)
126
+ * [extended_modules](http://ruby-doc.org/core-1.9.3/Module.html#method-i-included_modules)
106
127
 
107
128
 
108
129
  ## Testing
@@ -6,10 +6,12 @@ require 'eigenclass/version'
6
6
  module Eigenclass
7
7
  extend Forwardable
8
8
 
9
+ def_delegator :eigenclass, :alias_method, :ealias_method
9
10
  def_delegator :eigenclass, :attr_accessor, :eattr_accessor
10
11
  def_delegator :eigenclass, :attr_reader, :eattr_reader
11
12
  def_delegator :eigenclass, :attr_writer, :eattr_writer
12
13
  def_delegator :eigenclass, :define_method, :edefine_method
14
+ def_delegator :eigenclass, :included_modules, :extended_modules
13
15
  def_delegator :eigenclass, :instance_eval, :eigenclass_eval
14
16
  def_delegator :eigenclass, :instance_exec, :eigenclass_exec
15
17
 
@@ -1,3 +1,3 @@
1
1
  module Eigenclass
2
- VERSION = '2.0.2'
2
+ VERSION = '2.0.3'
3
3
  end
@@ -3,6 +3,10 @@ require_relative '../lib/eigenclass'
3
3
  RSpec.describe Eigenclass do
4
4
  subject { Object.new.extend(described_class) }
5
5
 
6
+ it { should delegate_method(:ealias_method)
7
+ .to(:eigenclass)
8
+ .as(:alias_method) }
9
+
6
10
  it { should delegate_method(:eattr_accessor)
7
11
  .to(:eigenclass)
8
12
  .as(:attr_accessor) }
@@ -19,6 +23,10 @@ RSpec.describe Eigenclass do
19
23
  .to(:eigenclass)
20
24
  .as(:define_method) }
21
25
 
26
+ it { should delegate_method(:extended_modules)
27
+ .to(:eigenclass)
28
+ .as(:included_modules) }
29
+
22
30
  describe '#eigenclass' do
23
31
  it 'should return the eigenclass instance' do
24
32
  expected = class << subject; self end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eigenclass
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Huber
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-07 00:00:00.000000000 Z
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codeclimate-test-reporter