charcoal 2.9.0 → 2.10.0
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/charcoal/controller_filter.rb +20 -11
- data/lib/charcoal/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d6b4e6622a16e47340ea4ec1e12bce7fea96b7defdde516b6429fb67b4df194
|
|
4
|
+
data.tar.gz: 299a143a93b04ff7441739ac0053f858d451fd6322ecf16554b55666be29e469
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 846ddfb37eecc961773ea3b17db4482f437bb3f5fe015f668529a500d6b4666ac9e9adbbf97a265109686169dc1e77e933a00e30b665f65bd07989a2c2488907
|
|
7
|
+
data.tar.gz: 7aa90055e84fe914a31d6de038bf11228be998e25b8ebc5d265332104c56b74fa894de87f05705f6e34834b659aad4326a855375f3565f41b0d47d4ad29d4646
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
require "active_support/core_ext/array/extract_options"
|
|
2
|
+
require "active_support/core_ext/hash/keys"
|
|
3
|
+
|
|
1
4
|
module Charcoal
|
|
2
5
|
module ControllerFilter
|
|
3
6
|
def self.included(klass)
|
|
@@ -8,17 +11,17 @@ module Charcoal
|
|
|
8
11
|
def allow(filter, &block)
|
|
9
12
|
action = "allow_#{filter}"
|
|
10
13
|
define_method action do |*args|
|
|
11
|
-
|
|
12
|
-
options = args.last.is_a?(Hash) ? args.pop : {}
|
|
14
|
+
options = args.extract_options!
|
|
13
15
|
options.assert_valid_keys(:only, :except, :if, :unless)
|
|
14
16
|
|
|
15
17
|
methods = args.map(&:to_sym)
|
|
16
18
|
methods = [:all] if methods.empty?
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if_conditions = Array(options[:if]).map { |condition| parse_directive(condition) }
|
|
21
|
+
unless_conditions = Array(options[:unless]).map { |condition| parse_directive(condition) }
|
|
22
|
+
directive = lambda do |controller|
|
|
23
|
+
if_conditions.all? { |condition| condition.call(controller) } &&
|
|
24
|
+
unless_conditions.none? { |condition| condition.call(controller) }
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
methods.each do |method|
|
|
@@ -31,12 +34,18 @@ module Charcoal
|
|
|
31
34
|
private
|
|
32
35
|
|
|
33
36
|
def parse_directive(directive)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
case directive
|
|
38
|
+
when Symbol, String
|
|
39
|
+
lambda { |controller| controller.send(directive.to_sym) }
|
|
40
|
+
when Proc
|
|
41
|
+
# Like Rails callbacks, evaluate blocks in the controller's context.
|
|
42
|
+
if directive.parameters.any? { |kind, _| [:req, :opt, :rest].include?(kind) }
|
|
43
|
+
lambda { |controller| controller.instance_exec(controller, &directive) }
|
|
44
|
+
else
|
|
45
|
+
lambda { |controller| controller.instance_exec(&directive) }
|
|
46
|
+
end
|
|
38
47
|
else
|
|
39
|
-
lambda { |
|
|
48
|
+
directive.respond_to?(:call) ? directive : lambda { |_| directive }
|
|
40
49
|
end
|
|
41
50
|
end
|
|
42
51
|
end
|
data/lib/charcoal/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: charcoal
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steven Davidovitz
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '7.
|
|
19
|
+
version: '7.1'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '7.
|
|
26
|
+
version: '7.1'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: actionpack
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '7.
|
|
33
|
+
version: '7.1'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '7.
|
|
40
|
+
version: '7.1'
|
|
41
41
|
description: Helps you support JSONP and CORS in your Rails app
|
|
42
42
|
email: sdavidovitz@zendesk.com
|
|
43
43
|
executables: []
|
|
@@ -63,14 +63,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
63
63
|
requirements:
|
|
64
64
|
- - ">="
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '3.
|
|
66
|
+
version: '3.3'
|
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
68
|
requirements:
|
|
69
69
|
- - ">="
|
|
70
70
|
- !ruby/object:Gem::Version
|
|
71
71
|
version: '0'
|
|
72
72
|
requirements: []
|
|
73
|
-
rubygems_version: 3.
|
|
73
|
+
rubygems_version: 3.5.22
|
|
74
74
|
signing_key:
|
|
75
75
|
specification_version: 4
|
|
76
76
|
summary: Cross-Origin helper for Rails
|