effective_resources 1.0.10 → 1.0.11
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/app/helpers/effective_resources_helper.rb +16 -13
- data/lib/effective_resources/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d9ccd3b1483ba66ad4dbdfd40a2b64ee43ec34d
|
4
|
+
data.tar.gz: e0717b61c8a8c49e62d9221d8e938ce8f37c2b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad00c6cd0e80ec4145f4e1b708d986649b150f5add0f4a47e68dc063456afd4ad55b5ecfc37ed8b5277c3166a88787c821fcaf6065cd4ae7c912be3f335a5d1
|
7
|
+
data.tar.gz: 5e8954119d5bba19d2d2bd816e38312691f7916124af6d20659c0bdd37309942e0c19bc9d5e65b379a133b0630c98f7e648da5a964de79b1eda0a0b34e9b792e
|
@@ -60,20 +60,23 @@ module EffectiveResourcesHelper
|
|
60
60
|
raise 'expected first argument to be an ActiveRecord::Base object or Array of objects' unless resource.kind_of?(ActiveRecord::Base) || resource.kind_of?(Class) || resource.kind_of?(Array)
|
61
61
|
raise 'expected attributes to be a Hash' unless atts.kind_of?(Hash)
|
62
62
|
|
63
|
-
btn_class = atts
|
64
|
-
locals = atts
|
65
|
-
partial = atts
|
66
|
-
spacer_template = locals
|
67
|
-
|
68
|
-
effective_resource = (atts
|
69
|
-
namespace = atts
|
70
|
-
|
71
|
-
|
72
|
-
actions
|
63
|
+
btn_class = atts[:btn_class]
|
64
|
+
locals = atts[:locals] || {}
|
65
|
+
partial = atts[:partial]
|
66
|
+
spacer_template = locals[:spacer_template]
|
67
|
+
|
68
|
+
effective_resource = (atts[:effective_resource] || find_effective_resource)
|
69
|
+
namespace = atts[:namespace] || (effective_resource.namespace.to_sym if effective_resource.namespace)
|
70
|
+
|
71
|
+
# Assign actions
|
72
|
+
actions = if atts.key?(:actions) # We filter out any actions passed to us that aren't supported
|
73
|
+
available = effective_resource.actions # [:new, :edit, ...]
|
74
|
+
atts[:actions].inject({}) { |h, (commit, opts)| h[commit] = opts if available.include?(opts[:action]); h }
|
75
|
+
else
|
76
|
+
(resource.kind_of?(Class) ? effective_resource.resource_klass_actions : effective_resource.resource_actions)
|
77
|
+
end
|
73
78
|
|
74
|
-
# Filter
|
75
|
-
action_keys = effective_resource.actions
|
76
|
-
raise "unknown action for #{effective_resource.name}: #{(atts.keys - action_keys).join(' ')}." if (atts.keys - action_keys).present?
|
79
|
+
# Filter out false and proc false
|
77
80
|
actions = actions.select { |_, v| atts[v[:action]].respond_to?(:call) ? instance_exec(&atts[v[:action]]) : (atts[v[:action]] != false) }
|
78
81
|
|
79
82
|
# Select Partial
|