heredity 0.1.0 → 0.1.1

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.
@@ -0,0 +1,19 @@
1
+ class Class
2
+ def inherited(klass)
3
+ # Check the class instance variable so we don't eagerly initialize empty
4
+ # arrays for every class (i.e. object).
5
+ return if @inherited_hooks.nil?
6
+
7
+ inherited_hooks.each do |block|
8
+ klass.class_eval(&block)
9
+ end
10
+ end
11
+
12
+ def inherited_hooks
13
+ @inherited_hooks ||= []
14
+ end
15
+
16
+ def on_inherit(&block)
17
+ inherited_hooks << block
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Heredity
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/heredity.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "heredity/core_ext/class"
1
2
  require "heredity/inheritable_class_instance_variables"
2
3
 
3
4
  require "heredity/version"
@@ -5,32 +6,7 @@ require "heredity/version"
5
6
  module Heredity
6
7
  def self.included(klass)
7
8
  klass.class_eval do
8
- extend ::Heredity::ClassMethods
9
9
  include ::Heredity::InheritableClassInstanceVariables
10
-
11
- class << self
12
- alias_method :inheritance_eval, :on_inherit
13
- alias_method :inherited_eval, :on_inherit
14
- alias_method :when_inherited, :on_inherit
15
- end
16
- end
17
- end
18
-
19
- module ClassMethods
20
- def _heredity_inherited_hooks
21
- @_heredity_inherited_hooks ||= []
22
- end
23
-
24
- def inherited(klass)
25
- super
26
-
27
- _heredity_inherited_hooks.each do |block|
28
- klass.class_eval(&block)
29
- end
30
- end
31
-
32
- def on_inherit(&block)
33
- _heredity_inherited_hooks << block
34
10
  end
35
11
  end
36
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heredity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-28 00:00:00.000000000 Z
12
+ date: 2013-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -105,6 +105,7 @@ files:
105
105
  - Rakefile
106
106
  - heredity.gemspec
107
107
  - lib/heredity.rb
108
+ - lib/heredity/core_ext/class.rb
108
109
  - lib/heredity/inheritable_class_instance_variables.rb
109
110
  - lib/heredity/version.rb
110
111
  - spec/heredity/inheritable_class_instance_variables_spec.rb
@@ -124,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
125
  version: '0'
125
126
  segments:
126
127
  - 0
127
- hash: -1055722602779099653
128
+ hash: 252453511989656056
128
129
  required_rubygems_version: !ruby/object:Gem::Requirement
129
130
  none: false
130
131
  requirements:
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  version: '0'
134
135
  segments:
135
136
  - 0
136
- hash: -1055722602779099653
137
+ hash: 252453511989656056
137
138
  requirements: []
138
139
  rubyforge_project:
139
140
  rubygems_version: 1.8.24