ocean-rails 2.10.0 → 2.10.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 +4 -4
- data/lib/ocean-rails.rb +26 -5
- data/lib/ocean/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: fbd8005493023e3421fad5e17b6f141bd484f249
|
4
|
+
data.tar.gz: 5103477f62b4d283d8d0db84948606a1e1b3d054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d40805d7d915875b4cb88834cbc9291c4488633a74f3581648ba4e395afbbd96c7254f7253b6d3883e8a0c3773bce2c93726123fd7b2e6a0ac91dc56af7d55
|
7
|
+
data.tar.gz: 07ac89cd9536620bc15441c1ad10d12e5ae70d63f1e3d4239977bab241853e4cc944ae2c2aa6ec02de45ee68c707e3a01c6c9647efb7230186c91da729e07a82
|
data/lib/ocean-rails.rb
CHANGED
@@ -68,10 +68,31 @@ end
|
|
68
68
|
#
|
69
69
|
def add_right_restrictions(rel, restrictions)
|
70
70
|
return rel unless restrictions
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
# First get the table to use as a basis for the OR clauses
|
72
|
+
t = rel.arel_table
|
73
|
+
# Accumulating Arel AND clauses
|
74
|
+
cond = restrictions.inject([]) do |acc, rr|
|
75
|
+
app = rr['app']
|
76
|
+
context = rr['context']
|
77
|
+
if app != '*' && context != '*'
|
78
|
+
acc << t[:app].eq(app).and(t[:context].eq(context))
|
79
|
+
elsif app != '*' && context == '*'
|
80
|
+
acc << t[:app].eq(app)
|
81
|
+
elsif app == '*' && context != '*'
|
82
|
+
acc << t[:context].eq(context)
|
83
|
+
end
|
84
|
+
acc
|
85
|
+
end
|
86
|
+
# Process the clauses. We might not need to OR anything.
|
87
|
+
case cond.length
|
88
|
+
when 0
|
89
|
+
return rel
|
90
|
+
when 1
|
91
|
+
return rel.where(cond.first)
|
92
|
+
else
|
93
|
+
# OR the multiple clauses together
|
94
|
+
cond = cond.inject { |a, b| a.or(b) }
|
95
|
+
# Return a relation built from the Arel condition we've constructed
|
96
|
+
rel.where(cond)
|
75
97
|
end
|
76
|
-
rel
|
77
98
|
end
|
data/lib/ocean/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocean-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bengtson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|