effective_resources 0.7.0 → 0.7.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63c9976e91dbea32eaa92ee0213e89a5ec269cd3
|
4
|
+
data.tar.gz: b48931b04be6d3e2efd48a4fb180bade8b7287c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c7dec755e65f89fada642b273f407d3c8c293e078fd705ac83e61efec021d0e3de154f9bd9b2318b980a711af0fee991c74ae39dc9e71461dbdf69dd535fd6d
|
7
|
+
data.tar.gz: eaeac90e0905b8cf25007007a77bb0a03e7d8f7f5d9cfd42bb9c0e675c74fc11adc715d45fd0341aa8aadb0995f84cc56d56b60d57ac1d935498842ebca4feec
|
@@ -13,16 +13,22 @@ module Effective
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
define_callbacks :resource_render
|
16
|
+
define_callbacks :resource_render, :resource_save, :resource_error
|
17
17
|
end
|
18
18
|
|
19
19
|
module ClassMethods
|
20
20
|
|
21
21
|
# https://github.com/rails/rails/blob/v5.1.4/actionpack/lib/abstract_controller/callbacks.rb
|
22
22
|
def before_render(*names, &blk)
|
23
|
-
_insert_callbacks(names, blk)
|
24
|
-
|
25
|
-
|
23
|
+
_insert_callbacks(names, blk) { |name, options| set_callback(:resource_render, :before, name, options) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def after_save(*names, &blk)
|
27
|
+
_insert_callbacks(names, blk) { |name, options| set_callback(:resource_save, :after, name, options) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def after_error(*names, &blk)
|
31
|
+
_insert_callbacks(names, blk) { |name, options| set_callback(:resource_error, :after, name, options) }
|
26
32
|
end
|
27
33
|
|
28
34
|
# Add the following to your controller for a simple member action
|
@@ -304,6 +310,7 @@ module Effective
|
|
304
310
|
resource_klass.transaction do
|
305
311
|
begin
|
306
312
|
resource.public_send("#{action}!") || raise("failed to #{action} #{resource}")
|
313
|
+
run_callbacks(:resource_save)
|
307
314
|
return true
|
308
315
|
rescue => e
|
309
316
|
flash.delete(:success)
|
@@ -312,6 +319,7 @@ module Effective
|
|
312
319
|
end
|
313
320
|
end
|
314
321
|
|
322
|
+
run_callbacks(:resource_error)
|
315
323
|
false
|
316
324
|
end
|
317
325
|
|
@@ -110,11 +110,7 @@ module EffectiveResourcesHelper
|
|
110
110
|
|
111
111
|
def glyphicon_to(icon, path, options = {})
|
112
112
|
content_tag(:a, options.merge(href: path)) do
|
113
|
-
|
114
|
-
content_tag(:span, '', class: "glyphicon #{icon}")
|
115
|
-
else
|
116
|
-
content_tag(:span, '', class: "glyphicon glyphicon-#{icon}")
|
117
|
-
end
|
113
|
+
glyphicon_tag(icon)
|
118
114
|
end
|
119
115
|
end
|
120
116
|
alias_method :bootstrap_icon_to, :glyphicon_to
|
@@ -56,7 +56,9 @@ module Effective
|
|
56
56
|
if res.max_id > max_id
|
57
57
|
{ as: :string }
|
58
58
|
else
|
59
|
-
if res.klass.unscoped.respond_to?(:
|
59
|
+
if res.klass.unscoped.respond_to?(:datatables_scope)
|
60
|
+
{ collection: res.klass.datatables_scope.map { |obj| [obj.to_s, obj.to_param] } }
|
61
|
+
elsif res.klass.unscoped.respond_to?(:datatables_filter)
|
60
62
|
{ collection: res.klass.datatables_filter.map { |obj| [obj.to_s, obj.to_param] } }
|
61
63
|
elsif res.klass.unscoped.respond_to?(:sorted)
|
62
64
|
{ collection: res.klass.sorted.map { |obj| [obj.to_s, obj.to_param] } }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|