zertico 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zertico/controller.rb +11 -7
- data/lib/zertico/version.rb +1 -1
- data/spec/zertico/controller_spec.rb +16 -0
- metadata +4 -4
data/lib/zertico/controller.rb
CHANGED
@@ -13,41 +13,45 @@ module Zertico
|
|
13
13
|
|
14
14
|
def index
|
15
15
|
initialize_object all
|
16
|
+
respond_with(instance_variable_get("@responder"))
|
16
17
|
end
|
17
18
|
|
18
19
|
def new
|
19
20
|
initialize_object build
|
21
|
+
respond_with(instance_variable_get("@responder"))
|
20
22
|
end
|
21
23
|
|
22
24
|
def show
|
23
25
|
initialize_object find(params[:id])
|
26
|
+
respond_with(instance_variable_get("@responder"))
|
24
27
|
end
|
25
28
|
|
26
29
|
def edit
|
27
30
|
initialize_object find(params[:id])
|
31
|
+
respond_with(instance_variable_get("@responder"))
|
28
32
|
end
|
29
33
|
|
30
34
|
def create
|
31
35
|
initialize_object generate(params[interface_name.to_sym])
|
32
|
-
respond_with(instance_variable_get(@
|
36
|
+
respond_with(instance_variable_get("@responder"))
|
33
37
|
end
|
34
38
|
|
35
39
|
def update
|
36
40
|
initialize_object modify(params[:id], params[interface_name.to_sym])
|
37
|
-
respond_with(instance_variable_get(@
|
41
|
+
respond_with(instance_variable_get("@responder"))
|
38
42
|
end
|
39
43
|
|
40
44
|
def destroy
|
41
45
|
initialize_object delete(params[:id])
|
42
|
-
respond_with(instance_variable_get(@
|
46
|
+
respond_with(instance_variable_get("@responder"))
|
43
47
|
end
|
44
48
|
|
45
49
|
protected
|
46
50
|
|
47
|
-
def initialize_object(
|
48
|
-
|
49
|
-
|
50
|
-
instance_variable_set(@
|
51
|
+
def initialize_object(objects = {})
|
52
|
+
objects.each do |key, value|
|
53
|
+
instance_variable_set("@#{key}", value)
|
54
|
+
instance_variable_set("@responder", value) unless @responder
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
data/lib/zertico/version.rb
CHANGED
@@ -20,9 +20,22 @@ describe Zertico::Controller do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
context 'with a custom object to respond' do
|
24
|
+
before :each do
|
25
|
+
controller.stub(:all).and_return({ :user => 'user', :responder => 'admin' })
|
26
|
+
controller.stub(:respond_with)
|
27
|
+
controller.index
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should intialize an object with it' do
|
31
|
+
controller.instance_variable_get('@responder').should == 'admin'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
23
35
|
context '#index' do
|
24
36
|
before :each do
|
25
37
|
controller.stub(:all).and_return({ :user => 'user' })
|
38
|
+
controller.stub(:respond_with)
|
26
39
|
controller.index
|
27
40
|
end
|
28
41
|
|
@@ -34,6 +47,7 @@ describe Zertico::Controller do
|
|
34
47
|
context '#new' do
|
35
48
|
before :each do
|
36
49
|
controller.stub(:build).and_return({ :user => 'user' })
|
50
|
+
controller.stub(:respond_with)
|
37
51
|
controller.new
|
38
52
|
end
|
39
53
|
|
@@ -46,6 +60,7 @@ describe Zertico::Controller do
|
|
46
60
|
before :each do
|
47
61
|
controller.stub(:params).and_return({ :id => 1 })
|
48
62
|
controller.stub(:find).and_return({ :user => 'user' })
|
63
|
+
controller.stub(:respond_with)
|
49
64
|
controller.show
|
50
65
|
end
|
51
66
|
|
@@ -58,6 +73,7 @@ describe Zertico::Controller do
|
|
58
73
|
before :each do
|
59
74
|
controller.stub(:params).and_return({ :id => 1 })
|
60
75
|
controller.stub(:find).and_return({ :user => 'user' })
|
76
|
+
controller.stub(:respond_with)
|
61
77
|
controller.edit
|
62
78
|
end
|
63
79
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zertico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
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-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
segments:
|
109
109
|
- 0
|
110
|
-
hash: -
|
110
|
+
hash: -1517778425785026116
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
none: false
|
113
113
|
requirements:
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
segments:
|
118
118
|
- 0
|
119
|
-
hash: -
|
119
|
+
hash: -1517778425785026116
|
120
120
|
requirements: []
|
121
121
|
rubyforge_project:
|
122
122
|
rubygems_version: 1.8.25
|