compound 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/compound/host.rb +24 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33141f001b6ef9e7acc84551774860fcec67d5a7
4
- data.tar.gz: 482d9e2556a07b9c52c72b459e1edea83e48f2e6
3
+ metadata.gz: 181b94c6776d1379869afc8657cc94a68ea6e4f7
4
+ data.tar.gz: db7ab0591074427d8cc44d9bed95e81a41a770f2
5
5
  SHA512:
6
- metadata.gz: c8d844bb989e3ce8fae996bfcec6a03ecbbe9df39ee4fc69c7ff0b8c491e0e064ffda298230930dee661bd68858daf45b791fcaebfc8854cc352914c6719c367
7
- data.tar.gz: c224e9c8fee830e26071e5554ec7ee23e2fd42ad41c3a1f3522d0f03b28a8ae99518524d4aea9c6cff72d8a9b09ebc56936b71fd3a3d1f3817d980a739e6aa1d
6
+ metadata.gz: b72e013523be28ff8760205b4365e1bbb8f000b55972fe998d14d9cae591cdf1ce5e5f7cc4521d027ac79cbb35e6e6ad11ca73da3ac4a32428fefa3a25f1bd42
7
+ data.tar.gz: 7d722c7575b99f567d48a5599d642a5e794105ae346cad714842114b9d49017c7f66f7c4d7608c3484823a817d23b6a8ab99d6becc143b1bcce62a62ef22d5ea
data/lib/compound/host.rb CHANGED
@@ -9,7 +9,16 @@ module Compound
9
9
 
10
10
  # Internalize a new Part embodying the given module
11
11
  def compound mod
12
- @_compound_parts ||= []
12
+ first_time_array = nil
13
+ @_compound_parts ||= (first_time_array=[])
14
+
15
+ # Pretend that the compounded modules are in the inheritance tree
16
+ singleton_class.send :define_singleton_method, :ancestors do
17
+ super() + first_time_array.map { |part|
18
+ part.instance_variable_get(:@_compound_component_module)
19
+ }
20
+ end if first_time_array
21
+
13
22
  uncompound mod
14
23
  @_compound_parts.unshift ::Compound::Part.new self, mod
15
24
  mod.compounded(self) if mod.respond_to? :compounded
@@ -47,6 +56,20 @@ module Compound
47
56
  raise(NameError, "undefined method `#{sym}' for object `#{self}'")
48
57
  end
49
58
 
59
+ # Pretend that the compounded modules are in the inheritance tree
60
+ def kind_of? mod
61
+ super or !!(@_compound_parts && @_compound_parts.detect { |part|
62
+ part.instance_variable_get(:@_compound_component_module) == mod
63
+ })
64
+ end
65
+
66
+ # Pretend that the compounded modules are in the inheritance tree
67
+ def is_a? mod
68
+ super or !!(@_compound_parts && @_compound_parts.detect { |part|
69
+ part.instance_variable_get(:@_compound_component_module) == mod
70
+ })
71
+ end
72
+
50
73
  private
51
74
 
52
75
  # A private method to enumerate over all of the compound parts,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compound
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe McIlvain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-10 00:00:00.000000000 Z
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.2.0
128
+ rubygems_version: 2.2.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: compound