corn_starch 1.9.34 → 1.9.35

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8aaa293c4d5ab907eac1271668003a376d99c58c
4
- data.tar.gz: 55343a0f12c2df0430ded42918cdba1206804c59
3
+ metadata.gz: dfb7bc76d9c5bd6b6245e39782c39c772b2e884e
4
+ data.tar.gz: 5c8ea870877ea544157ceb1a91462258255920d1
5
5
  SHA512:
6
- metadata.gz: 123290fe02a36801e17799030b0a102cadb5e8bad64ae78b01be4feb77bccbf8f93d0100f01533378275434706683e38730b1252481eb93cc1cb89c9c8e1509d
7
- data.tar.gz: 9efce69c28ebaa7e1ecd8a6c46ff20a4b67412b965d62d845538df651f7b558e34047649f32bafa3894bc85706e2fa6aa8c579f695ebe32672bade205244bfb9
6
+ metadata.gz: 0538eca55686973e83a5dca2251b83796763c15e7956be72ebc8d24bfdbf40577d7c58669e79452f61d7e1b06d13640c863598279e7b8dab4b9227fe3eabc08f
7
+ data.tar.gz: 78dc0ede5c6084ef436bc3b23b57f911cf18f954a7af08f4364fbab3837a4eee374d87f104beb86650b7c8455d23809b6789eda3d24306decf4e800fadf9868d
@@ -38,22 +38,22 @@ module CornStarch
38
38
 
39
39
  # Authentication Filter
40
40
  def auth_filter
41
- redirect_to corn_starch.new_session_url, alert: { head: t('auth.access_denied'), body: t('auth.login_required') } unless is_authed
41
+ redirect_to corn_starch.new_session_url, notify_acs_denied('auth.login_required') unless is_authed
42
42
  end
43
43
 
44
44
  # Un-Authentication Filter
45
45
  def unauth_filter
46
- redirect_to root_url, alert: { head: t('auth.access_denied'), body: t('auth.already_logged_in') } if is_authed
46
+ redirect_to root_url, notify_acs_denied('auth.already_logged_in') if is_authed
47
47
  end
48
48
 
49
49
  # Self Filter
50
50
  def self_filter
51
- redirect_to root_url, alert: { head: t('auth.access_denied'), body: t('auth.invalid_user_id') } unless is_self
51
+ redirect_to root_url, notify_acs_denied('auth.invalid_user_id') unless is_self
52
52
  end
53
53
 
54
54
  # Not Self Filter
55
55
  def not_self_filter
56
- redirect_to root_url, alert: { head: t('auth.access_denied'), body: t('auth.invalid_user_id') } if is_self
56
+ redirect_to root_url, notify_acs_denied('auth.invalid_user_id') if is_self
57
57
  end
58
58
 
59
59
  # Pagination Filter
@@ -249,23 +249,15 @@ module CornStarch
249
249
  when :login then notify_res 'gen_msg.login', result_or_name, name: uname
250
250
  when :logout then notify 'gen_msg.logout'
251
251
 
252
- # Generic Resources
253
- when :create
254
- {
255
- pass: { head: t('gen_msg.create.pass.head', model: model), body: t('gen_msg.create.pass.body', model: model, name: ename) },
256
- fail: { head: t('gen_msg.create.fail.head', model: model), body: t('gen_msg.create.fail.body', errors: errors) }
257
- }[result_or_name]
258
- when :update
259
- {
260
- pass: { head: t('gen_msg.update.pass.head', model: model), body: t('gen_msg.update.pass.body', model: model, name: ename) },
261
- fail: { head: t('gen_msg.update.fail.head', model: model), body: t('gen_msg.update.fail.body', errors: errors) }
262
- }[result_or_name]
263
- when :destroy
264
- { head: t('gen_msg.destroy.head', model: model), body: t('gen_msg.destroy.body', model: model, name: result_or_name) }
265
-
266
- # Error
267
- else
268
- { head: t('gen_msg.unknown_action.head'), body: t('gen_msg.unknown_action.body', action: action) }
252
+ # Create / Update Resources
253
+ when :create then notify_res 'gen_msg.create', result_or_name, model: model, name: ename, errors: errors
254
+ when :update then notify_res 'gen_msg.update', result_or_name, model: model, name: ename, errors: errors
255
+
256
+ # Destroy Resources
257
+ when :destroy then notify 'gen_msg.destroy', { model: model, name: result_or_name }, { model: model }
258
+
259
+ # Unknown Action
260
+ else notify 'gen_msg.unknown_action', action: action
269
261
  end
270
262
  end
271
263
 
@@ -283,5 +275,10 @@ module CornStarch
283
275
  def notify_res key, res, head_hash = nil, body_hash = nil
284
276
  Hash[[:pass, :fail].map { |r| notify "#{key}.#{r}", head_hash, body_hash }][res]
285
277
  end
278
+
279
+ # Build Access-Denied Notification
280
+ def notify_acs_denied key
281
+ { alert: { head: t('auth.access_denied'), body: t(key) } }
282
+ end
286
283
  end
287
284
  end
@@ -1,3 +1,3 @@
1
1
  module CornStarch
2
- VERSION = '1.9.34'
2
+ VERSION = '1.9.35'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corn_starch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.34
4
+ version: 1.9.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eresse