dci-rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/dci-rails.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dci-rails}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nate Jackson"]
12
- s.date = %q{2011-09-16}
12
+ s.date = %q{2011-09-19}
13
13
  s.description = %q{helpers for rails to implement DCI pattern (http://andrzejonsoftware.blogspot.com/2011/02/dci-and-rails.html)}
14
14
  s.email = %q{nate.d.jackson@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -9,13 +9,17 @@ module DCI
9
9
  def extend_resource(resource_method, *extensions)
10
10
  class_eval do
11
11
  extensions.each do |extension|
12
- define_method("#{resource_method}_with_#{extension}") do
13
- send("#{resource_method}_without_#{extension}").tap do |obj|
12
+ with_method = "#{resource_method}_with_#{extension}"
13
+ without_method = "#{resource_method}_without_#{extension}"
14
+
15
+ define_method(with_method) do |*args|
16
+ instance_variable_get("@#{with_method}") || send(without_method, *args).tap do |obj|
14
17
  obj.extend(extension)
18
+ instance_variable_set("@#{with_method}", obj)
15
19
  end
16
20
  end
17
- alias_method "#{resource_method}_without_#{extension}", resource_method
18
- alias_method resource_method, "#{resource_method}_with_#{extension}"
21
+ alias_method without_method, resource_method
22
+ alias_method resource_method, with_method
19
23
  end
20
24
  end
21
25
  end
@@ -32,6 +32,33 @@ describe "DCI::Controller::DSL" do
32
32
  controller.resource.should respond_to(:extended_with_TestExtension2)
33
33
  controller.resource.should respond_to(:extended_with_TestExtension3)
34
34
  end
35
+
36
+ it "passes arguments through to the original resource method" do
37
+ resource_args = ["arg1", "arg2"]
38
+
39
+ controller.stub(:resource) do |*args|
40
+ args.should == resource_args
41
+ resource
42
+ end
43
+
44
+ (class << controller; self; end).instance_eval do
45
+ extend_resource :resource, TestExtension1
46
+ end
47
+
48
+ controller.resource(*resource_args).should respond_to(:extended_with_TestExtension1)
49
+ end
50
+
51
+ it "only extends the resource once" do
52
+ controller.resource = resource
53
+
54
+ resource.should_receive(:extend).once
55
+
56
+ (class << controller; self; end).instance_eval do
57
+ extend_resource :resource, TestExtension1
58
+ end
59
+
60
+ 5.times { controller.resource }
61
+ end
35
62
  end
36
63
  end
37
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dci-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-16 00:00:00.000000000 -05:00
12
+ date: 2011-09-19 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70258847961740 !ruby/object:Gem::Requirement
17
+ requirement: &70170204775520 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 2.3.0
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70258847961740
25
+ version_requirements: *70170204775520
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &70258847961100 !ruby/object:Gem::Requirement
28
+ requirement: &70170204774960 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70258847961100
36
+ version_requirements: *70170204774960
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: jeweler
39
- requirement: &70258847960460 !ruby/object:Gem::Requirement
39
+ requirement: &70170204774380 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.6.4
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70258847960460
47
+ version_requirements: *70170204774380
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rcov
50
- requirement: &70258847959820 !ruby/object:Gem::Requirement
50
+ requirement: &70170204773380 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70258847959820
58
+ version_requirements: *70170204773380
59
59
  description: helpers for rails to implement DCI pattern (http://andrzejonsoftware.blogspot.com/2011/02/dci-and-rails.html)
60
60
  email: nate.d.jackson@gmail.com
61
61
  executables: []
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  segments:
99
99
  - 0
100
- hash: -4225227550041907610
100
+ hash: 3087653526277293251
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  none: false
103
103
  requirements: