minimalizer 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/minimalizer/controller_helpers.rb +33 -6
- data/lib/minimalizer/engine.rb +0 -8
- data/lib/minimalizer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 638219c0b09d1604e575443a92adff59ab42bf91
|
4
|
+
data.tar.gz: 7fc17e2bcd5e66ea82d2494e1b36a49cbe17119f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08dc267a2969d516b50f1e8c119b802969463ce0ad837e65134e6e091eb1cbab4eaad6798bd4d89481ff270cc3ec2f8f3c95582f56168825cc04fcc783cfcd61
|
7
|
+
data.tar.gz: 6ad803728c6fb8ae2804dffb18046307d7507919458bf411a811221c02dc44f56ff69076f33678c75070f50d764a43dc7afc53fd703e54b53142051cf54cfcaa
|
@@ -43,12 +43,25 @@ module Minimalizer
|
|
43
43
|
# create_resource [@parent, @record], record_params
|
44
44
|
# end
|
45
45
|
#
|
46
|
+
# An optional :context argument will be passed to the record’s #save method
|
47
|
+
# to set the validation context.
|
48
|
+
#
|
49
|
+
# def create
|
50
|
+
# create_resource @record, record_params, context: :scenario
|
51
|
+
# end
|
52
|
+
#
|
46
53
|
# An optional :location argument will override the redirect location.
|
47
54
|
#
|
48
55
|
# def create
|
49
56
|
# create_resource @record, record_params, location: :records
|
50
57
|
# end
|
51
58
|
#
|
59
|
+
# An optional :template argument will override the default :new template.
|
60
|
+
#
|
61
|
+
# def create
|
62
|
+
# create_resource @record, record_params, template: :alternate
|
63
|
+
# end
|
64
|
+
#
|
52
65
|
# Passing a block will yield true if the model saves successfully, false
|
53
66
|
# otherwise.
|
54
67
|
#
|
@@ -61,11 +74,11 @@ module Minimalizer
|
|
61
74
|
# end
|
62
75
|
# end
|
63
76
|
# end
|
64
|
-
def create_resource(resource, attributes, location: nil)
|
77
|
+
def create_resource(resource, attributes, context: nil, location: nil, template: nil)
|
65
78
|
model = resource.is_a?(Array) ? resource.last : resource
|
66
79
|
model.assign_attributes attributes
|
67
80
|
|
68
|
-
if model.save
|
81
|
+
if model.save(context: context)
|
69
82
|
flash.notice = t('.notice')
|
70
83
|
yield true if block_given?
|
71
84
|
redirect_to location || resource
|
@@ -73,7 +86,7 @@ module Minimalizer
|
|
73
86
|
flash.now.alert = t('.alert')
|
74
87
|
response.status = 422
|
75
88
|
yield false if block_given?
|
76
|
-
render :new
|
89
|
+
render template || :new
|
77
90
|
end
|
78
91
|
end
|
79
92
|
|
@@ -94,12 +107,25 @@ module Minimalizer
|
|
94
107
|
# update_resource [@parent, @record], record_params
|
95
108
|
# end
|
96
109
|
#
|
110
|
+
# An optional :context argument will be passed to the record’s #save method
|
111
|
+
# to set the validation context.
|
112
|
+
#
|
113
|
+
# def update
|
114
|
+
# update_resource @record, record_params, context: :scenario
|
115
|
+
# end
|
116
|
+
#
|
97
117
|
# An optional :location argument will override the redirect location.
|
98
118
|
#
|
99
119
|
# def update
|
100
120
|
# update_resource @record, record_params, location: :records
|
101
121
|
# end
|
102
122
|
#
|
123
|
+
# An optional :template argument will override the default :edit template.
|
124
|
+
#
|
125
|
+
# def update
|
126
|
+
# update_resource @record, record_params, template: :alternate
|
127
|
+
# end
|
128
|
+
#
|
103
129
|
# Passing a block will yield true if the model updates successfully, false
|
104
130
|
# otherwise.
|
105
131
|
#
|
@@ -112,10 +138,11 @@ module Minimalizer
|
|
112
138
|
# end
|
113
139
|
# end
|
114
140
|
# end
|
115
|
-
def update_resource(resource, attributes, location: nil)
|
141
|
+
def update_resource(resource, attributes, context: nil, location: nil, template: nil)
|
116
142
|
model = resource.is_a?(Array) ? resource.last : resource
|
143
|
+
model.assign_attributes(attributes)
|
117
144
|
|
118
|
-
if model.
|
145
|
+
if model.save(context: context)
|
119
146
|
flash.notice = t('.notice')
|
120
147
|
yield true if block_given?
|
121
148
|
redirect_to location || resource
|
@@ -123,7 +150,7 @@ module Minimalizer
|
|
123
150
|
flash.now.alert = t('.alert')
|
124
151
|
response.status = 422
|
125
152
|
yield false if block_given?
|
126
|
-
render :edit
|
153
|
+
render template || :edit
|
127
154
|
end
|
128
155
|
end
|
129
156
|
|
data/lib/minimalizer/engine.rb
CHANGED
data/lib/minimalizer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimalizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theodore Kimble
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-test
|