memory_model 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/dictionaries/jwaldrip.xml +3 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/memory_model.iml +47 -0
- data/.idea/misc.xml +8 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/lib/memory_model/version.rb +1 -1
- data/memory_model.gemspec +5 -3
- metadata +37 -24
- data/lib/concerned_inheritance.rb +0 -27
- data/lib/concerned_inheritance/class_methods.rb +0 -28
- data/lib/concerned_inheritance/delegator.rb +0 -21
- data/lib/concerned_inheritance/module_methods.rb +0 -11
- data/spec/concerned_inheritance/class_methods_spec.rb +0 -57
- data/spec/concerned_inheritance/delegator_spec.rb +0 -52
- data/spec/concerned_inheritance/module_methods_spec.rb +0 -27
- data/spec/memory_model/concerned_inheritance_spec.rb +0 -24
data/.gitignore
CHANGED
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/.idea/encodings.xml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="NewModuleRootManager">
|
13
|
+
<content url="file://$MODULE_DIR$">
|
14
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
15
|
+
</content>
|
16
|
+
<orderEntry type="inheritedJdk" />
|
17
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="activemodel (v@6581d7, rbenv: 1.9.3-p362) [gem]" level="application" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="activesupport (v@6581d7, rbenv: 1.9.3-p362) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="builder (v3.0.4, rbenv: 1.9.3-p362) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.2.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="coderay (v1.0.8, rbenv: 1.9.3-p362) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="concerned_inheritance (v0.0.2, rbenv: 1.9.3-p362) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="guard (v1.6.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="guard-rspec (v2.3.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.6.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="ice_nine (v0.6.0, rbenv: 1.9.3-p362) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="listen (v0.7.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="lumberjack (v1.0.2, rbenv: 1.9.3-p362) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="method_source (v0.8.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.5.0, rbenv: 1.9.3-p362) [gem]" level="application" />
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="pry (v0.9.10, rbenv: 1.9.3-p362) [gem]" level="application" />
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="rb-fsevent (v0.9.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v2.12.0, rbenv: 1.9.3-p362) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.12.2, rbenv: 1.9.3-p362) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.12.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.12.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
39
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.7.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
40
|
+
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.7.1, rbenv: 1.9.3-p362) [gem]" level="application" />
|
41
|
+
<orderEntry type="library" scope="PROVIDED" name="slop (v3.3.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="terminal-notifier-guard (v1.5.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="test-unit (v2.5.3, rbenv: 1.9.3-p362) [gem]" level="application" />
|
44
|
+
<orderEntry type="library" scope="PROVIDED" name="thor (v0.16.0, rbenv: 1.9.3-p362) [gem]" level="application" />
|
45
|
+
</component>
|
46
|
+
</module>
|
47
|
+
|
data/.idea/misc.xml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectResources">
|
4
|
+
<default-html-doctype>$APPLICATION_HOME_DIR$/lib/rubymine.jar!/resources/html5-schema/html5.rnc</default-html-doctype>
|
5
|
+
</component>
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 1.9.3-p362" project-jdk-type="RUBY_SDK" />
|
7
|
+
</project>
|
8
|
+
|
data/.idea/modules.xml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/memory_model.iml" filepath="$PROJECT_DIR$/.idea/memory_model.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
9
|
+
|
data/.idea/vcs.xml
ADDED
data/lib/memory_model/version.rb
CHANGED
data/memory_model.gemspec
CHANGED
@@ -17,14 +17,16 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = %w{lib}
|
19
19
|
|
20
|
-
gem.
|
21
|
-
gem.
|
20
|
+
gem.add_dependency 'activemodel'
|
21
|
+
gem.add_dependency 'activesupport'
|
22
|
+
gem.add_dependency 'concerned_inheritance'
|
23
|
+
gem.add_dependency 'ice_nine'
|
24
|
+
|
22
25
|
gem.add_development_dependency 'guard-rspec'
|
23
26
|
gem.add_development_dependency 'rb-fsevent'
|
24
27
|
gem.add_development_dependency 'rspec'
|
25
28
|
gem.add_development_dependency 'simplecov'
|
26
29
|
gem.add_development_dependency 'terminal-notifier-guard'
|
27
|
-
gem.add_development_dependency 'ice_nine'
|
28
30
|
gem.add_development_dependency 'test-unit'
|
29
31
|
|
30
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memory_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activemodel
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: activesupport
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -19,7 +35,7 @@ dependencies:
|
|
19
35
|
- - ! '>='
|
20
36
|
- !ruby/object:Gem::Version
|
21
37
|
version: '0'
|
22
|
-
type: :
|
38
|
+
type: :runtime
|
23
39
|
prerelease: false
|
24
40
|
version_requirements: !ruby/object:Gem::Requirement
|
25
41
|
none: false
|
@@ -28,14 +44,14 @@ dependencies:
|
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
47
|
+
name: concerned_inheritance
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
35
51
|
- - ! '>='
|
36
52
|
- !ruby/object:Gem::Version
|
37
53
|
version: '0'
|
38
|
-
type: :
|
54
|
+
type: :runtime
|
39
55
|
prerelease: false
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
@@ -44,14 +60,14 @@ dependencies:
|
|
44
60
|
- !ruby/object:Gem::Version
|
45
61
|
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
63
|
+
name: ice_nine
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
49
65
|
none: false
|
50
66
|
requirements:
|
51
67
|
- - ! '>='
|
52
68
|
- !ruby/object:Gem::Version
|
53
69
|
version: '0'
|
54
|
-
type: :
|
70
|
+
type: :runtime
|
55
71
|
prerelease: false
|
56
72
|
version_requirements: !ruby/object:Gem::Requirement
|
57
73
|
none: false
|
@@ -60,7 +76,7 @@ dependencies:
|
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
79
|
+
name: guard-rspec
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
65
81
|
none: false
|
66
82
|
requirements:
|
@@ -76,7 +92,7 @@ dependencies:
|
|
76
92
|
- !ruby/object:Gem::Version
|
77
93
|
version: '0'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
95
|
+
name: rb-fsevent
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
81
97
|
none: false
|
82
98
|
requirements:
|
@@ -92,7 +108,7 @@ dependencies:
|
|
92
108
|
- !ruby/object:Gem::Version
|
93
109
|
version: '0'
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
111
|
+
name: rspec
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
97
113
|
none: false
|
98
114
|
requirements:
|
@@ -108,7 +124,7 @@ dependencies:
|
|
108
124
|
- !ruby/object:Gem::Version
|
109
125
|
version: '0'
|
110
126
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
127
|
+
name: simplecov
|
112
128
|
requirement: !ruby/object:Gem::Requirement
|
113
129
|
none: false
|
114
130
|
requirements:
|
@@ -124,7 +140,7 @@ dependencies:
|
|
124
140
|
- !ruby/object:Gem::Version
|
125
141
|
version: '0'
|
126
142
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
143
|
+
name: terminal-notifier-guard
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|
129
145
|
none: false
|
130
146
|
requirements:
|
@@ -164,6 +180,15 @@ extensions: []
|
|
164
180
|
extra_rdoc_files: []
|
165
181
|
files:
|
166
182
|
- .gitignore
|
183
|
+
- .idea/.rakeTasks
|
184
|
+
- .idea/dictionaries/jwaldrip.xml
|
185
|
+
- .idea/encodings.xml
|
186
|
+
- .idea/memory_model.iml
|
187
|
+
- .idea/misc.xml
|
188
|
+
- .idea/modules.xml
|
189
|
+
- .idea/scopes/scope_settings.xml
|
190
|
+
- .idea/vcs.xml
|
191
|
+
- .idea/workspace.xml
|
167
192
|
- .rspec
|
168
193
|
- .travis.yml
|
169
194
|
- Gemfile
|
@@ -171,10 +196,6 @@ files:
|
|
171
196
|
- LICENSE.txt
|
172
197
|
- README.md
|
173
198
|
- Rakefile
|
174
|
-
- lib/concerned_inheritance.rb
|
175
|
-
- lib/concerned_inheritance/class_methods.rb
|
176
|
-
- lib/concerned_inheritance/delegator.rb
|
177
|
-
- lib/concerned_inheritance/module_methods.rb
|
178
199
|
- lib/memory_model.rb
|
179
200
|
- lib/memory_model/base.rb
|
180
201
|
- lib/memory_model/base/actionable.rb
|
@@ -190,9 +211,6 @@ files:
|
|
190
211
|
- lib/memory_model/core_ext/object.rb
|
191
212
|
- lib/memory_model/version.rb
|
192
213
|
- memory_model.gemspec
|
193
|
-
- spec/concerned_inheritance/class_methods_spec.rb
|
194
|
-
- spec/concerned_inheritance/delegator_spec.rb
|
195
|
-
- spec/concerned_inheritance/module_methods_spec.rb
|
196
214
|
- spec/memory_model/base/actionable_spec.rb
|
197
215
|
- spec/memory_model/base/attributable_spec.rb
|
198
216
|
- spec/memory_model/base/collectable_spec.rb
|
@@ -204,7 +222,6 @@ files:
|
|
204
222
|
- spec/memory_model/base/versionable_spec.rb
|
205
223
|
- spec/memory_model/base_spec.rb
|
206
224
|
- spec/memory_model/collection_spec.rb
|
207
|
-
- spec/memory_model/concerned_inheritance_spec.rb
|
208
225
|
- spec/memory_model/core_ext/object_spec.rb
|
209
226
|
- spec/spec_helper.rb
|
210
227
|
- spec/support/active_model_lint.rb
|
@@ -233,9 +250,6 @@ signing_key:
|
|
233
250
|
specification_version: 3
|
234
251
|
summary: An in memory, ORM
|
235
252
|
test_files:
|
236
|
-
- spec/concerned_inheritance/class_methods_spec.rb
|
237
|
-
- spec/concerned_inheritance/delegator_spec.rb
|
238
|
-
- spec/concerned_inheritance/module_methods_spec.rb
|
239
253
|
- spec/memory_model/base/actionable_spec.rb
|
240
254
|
- spec/memory_model/base/attributable_spec.rb
|
241
255
|
- spec/memory_model/base/collectable_spec.rb
|
@@ -247,7 +261,6 @@ test_files:
|
|
247
261
|
- spec/memory_model/base/versionable_spec.rb
|
248
262
|
- spec/memory_model/base_spec.rb
|
249
263
|
- spec/memory_model/collection_spec.rb
|
250
|
-
- spec/memory_model/concerned_inheritance_spec.rb
|
251
264
|
- spec/memory_model/core_ext/object_spec.rb
|
252
265
|
- spec/spec_helper.rb
|
253
266
|
- spec/support/active_model_lint.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'active_support/concern'
|
2
|
-
require 'active_support/core_ext/class/attribute'
|
3
|
-
require 'active_support/dependencies/autoload'
|
4
|
-
|
5
|
-
module ConcernedInheritance
|
6
|
-
extend ActiveSupport::Autoload
|
7
|
-
|
8
|
-
autoload :Delegator
|
9
|
-
autoload :ClassMethods
|
10
|
-
autoload :ModuleMethods
|
11
|
-
|
12
|
-
def self.extended(base)
|
13
|
-
case base
|
14
|
-
when Class
|
15
|
-
base.extend ClassMethods
|
16
|
-
when Module
|
17
|
-
base.extend ModuleMethods
|
18
|
-
end
|
19
|
-
base.instance_variable_set :@inherited_callbacks, [] unless base.instance_variable_defined? :@inherited_callbacks
|
20
|
-
end
|
21
|
-
|
22
|
-
def define_inherited_callback(&block)
|
23
|
-
raise ArgumentError, 'missing required block' unless block_given?
|
24
|
-
@inherited_callbacks += [block]
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module ConcernedInheritance::ClassMethods
|
2
|
-
|
3
|
-
def inherited_callbacks
|
4
|
-
(self.singleton_class.ancestors + self.ancestors).select do |ancestor|
|
5
|
-
ancestor.instance_variable_defined? :@inherited_callbacks
|
6
|
-
end.map do |ancestor|
|
7
|
-
ancestor.instance_variable_get :@inherited_callbacks
|
8
|
-
end.flatten
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def inherited(subclass=nil, &block)
|
14
|
-
if subclass.nil?
|
15
|
-
define_inherited_callback(&block)
|
16
|
-
else
|
17
|
-
run_inherited_callbacks(subclass)
|
18
|
-
super(subclass)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def run_inherited_callbacks(subclass)
|
23
|
-
self.inherited_callbacks.each do |callback|
|
24
|
-
ConcernedInheritance::Delegator.new(self, subclass, callback)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class ConcernedInheritance::Delegator < BasicObject
|
2
|
-
|
3
|
-
attr_reader :baseclass, :subclass
|
4
|
-
|
5
|
-
def initialize(baseclass, subclass, callback)
|
6
|
-
@baseclass = baseclass
|
7
|
-
@subclass = subclass
|
8
|
-
if callback.not_a?(::Proc)
|
9
|
-
raise ::ArgumentError, "#{callback} must be a proc"
|
10
|
-
elsif (-1..0).cover?(callback.arity)
|
11
|
-
instance_eval(&callback)
|
12
|
-
else
|
13
|
-
raise ::ArgumentError, "#{callback} must have an arity of 0, got #{callback.arity}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def method_missing(m, *args, &block)
|
18
|
-
subclass.send m, *args, &block
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'concerned_inheritance'
|
3
|
-
|
4
|
-
describe ConcernedInheritance::ClassMethods do
|
5
|
-
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
extend ConcernedInheritance
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '.inherited' do
|
13
|
-
|
14
|
-
context 'with a subclass' do
|
15
|
-
it 'should call run inherited callbacks' do
|
16
|
-
mock_subclass = mock
|
17
|
-
klass.should_receive(:run_inherited_callbacks).with(mock_subclass)
|
18
|
-
klass.send :inherited, mock_subclass
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'with a block' do
|
23
|
-
it 'should call define_inherited_callback' do
|
24
|
-
block = Proc.new { }
|
25
|
-
klass.should_receive(:define_inherited_callback).with(&block)
|
26
|
-
klass.send :inherited, &block
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '.inherited_callbacks' do
|
33
|
-
it 'should call off to its ancestors' do
|
34
|
-
mock_ancestor = mock
|
35
|
-
mock_callback = proc { "Bar" }
|
36
|
-
mock_ancestor.instance_variable_set :@inherited_callbacks, [mock_callback]
|
37
|
-
klass.singleton_class.stub(:ancestors).and_return([mock_ancestor])
|
38
|
-
klass.stub(:ancestors).and_return([mock_ancestor])
|
39
|
-
klass.inherited_callbacks.size.should > 0
|
40
|
-
klass.inherited_callbacks.each do |callback|
|
41
|
-
callback.should == mock_callback
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '.run_inherited_callbacks' do
|
47
|
-
it 'should initialize an InheritanceDelegator' do
|
48
|
-
mock_subclass = mock
|
49
|
-
mock_callback = proc { }
|
50
|
-
ConcernedInheritance::Delegator.should_receive(:new).with(klass, mock_subclass, mock_callback)
|
51
|
-
klass.send :define_inherited_callback, &mock_callback
|
52
|
-
klass.send :run_inherited_callbacks, mock_subclass
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'concerned_inheritance'
|
3
|
-
|
4
|
-
describe ConcernedInheritance::Delegator do
|
5
|
-
|
6
|
-
let(:baseclass) { Class.new }
|
7
|
-
let(:subclass) { Class.new }
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
context 'given a proc with no arity' do
|
11
|
-
let(:callback) do
|
12
|
-
proc { 'foo' }
|
13
|
-
end
|
14
|
-
it "should should call a subclass' instance method" do
|
15
|
-
expect { ConcernedInheritance::Delegator.new(baseclass, subclass, callback) }.to_not raise_error ArgumentError
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should instance_eval the callback' do
|
19
|
-
callback = proc { foo }
|
20
|
-
subclass.should_receive(:foo)
|
21
|
-
ConcernedInheritance::Delegator.new(baseclass, subclass, callback)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'given a proc with arity' do
|
26
|
-
let(:callback) do
|
27
|
-
proc { |foo| foo }
|
28
|
-
end
|
29
|
-
it 'should raise an error' do
|
30
|
-
expect { ConcernedInheritance::Delegator.new(baseclass, subclass, callback) }.to raise_error ArgumentError
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'when not given a proc' do
|
35
|
-
it 'should raise an error' do
|
36
|
-
expect { ConcernedInheritance::Delegator.new(baseclass, subclass, Object.new) }.to raise_error ArgumentError
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#method_missing' do
|
42
|
-
let(:callback) { proc { } }
|
43
|
-
it 'should call a method on the subclass' do
|
44
|
-
block = proc { }
|
45
|
-
subclass.should_receive(:foo).with('bar', 'baz', &block)
|
46
|
-
delegator = ConcernedInheritance::Delegator.new(baseclass, subclass, callback)
|
47
|
-
delegator.foo 'bar', 'baz', &block
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'concerned_inheritance'
|
3
|
-
|
4
|
-
describe ConcernedInheritance::ModuleMethods do
|
5
|
-
let(:the_module) do
|
6
|
-
Module.new do
|
7
|
-
extend ConcernedInheritance
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '.define_inherited_callback' do
|
12
|
-
it 'should include the callback' do
|
13
|
-
block = Proc.new { }
|
14
|
-
the_module.send :define_inherited_callback, &block
|
15
|
-
the_module.inherited_callbacks.should include block
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '.inherited' do
|
20
|
-
it 'should call define_inherited_callback' do
|
21
|
-
block = Proc.new { }
|
22
|
-
the_module.should_receive(:define_inherited_callback).with(&block)
|
23
|
-
the_module.send :inherited, &block
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'concerned_inheritance'
|
3
|
-
|
4
|
-
describe ConcernedInheritance do
|
5
|
-
|
6
|
-
let(:klass) do
|
7
|
-
Class.new do
|
8
|
-
extend ConcernedInheritance
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '.extended' do
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '.define_inherited_callback' do
|
17
|
-
it 'should include the callback' do
|
18
|
-
block = Proc.new { }
|
19
|
-
klass.send :define_inherited_callback, &block
|
20
|
-
klass.instance_variable_get(:@inherited_callbacks).should include block
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|