remote_db 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/remote_db/concerns/restricted_columns.rb +17 -9
- data/lib/remote_db/version.rb +1 -1
- data/spec/concerns/configurable_spec.rb +2 -2
- 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: 8e73a3ed8c1a47239b1e830675503fd7c9950166
|
4
|
+
data.tar.gz: f2b0b31ab87a254510d8b5105bbb12953f15d726
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06d936571f953b49b43d06ae81e3ffdbe004abc30edca2d8691445999d5d7278157074f28fff6dea7621dac06dae65e0d69a5508ff3180e9fe26a3f4752e7198
|
7
|
+
data.tar.gz: 493861ce02eac98fa121e227320f62014ec7b62ac34ac2e972a72b3eee5dcbbbe8244bdb72a0f5f13609607dbfeec7b79aa37d17549d754e016cf880279f9eb8
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,17 +6,25 @@ module RemoteDb
|
|
6
6
|
class ForbiddenColumnException < Exception; end
|
7
7
|
|
8
8
|
included do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
# Rails 4.2 introduced a new attribute reader method `_read_attribute`.
|
10
|
+
# However, older versions of Rails (<= 4.1) use `read_attribute`.
|
11
|
+
[:_read_attribute, :read_attribute].each do |method|
|
12
|
+
if self.method_defined?(method)
|
13
|
+
define_method("#{method}_with_safety") do |name|
|
14
|
+
original_db_column = self.class.original_columns.include?(name.to_sym)
|
15
|
+
visible_db_column = self.class.visible_columns.include? (name.to_sym)
|
16
|
+
|
17
|
+
if (original_db_column && visible_db_column) || !original_db_column
|
18
|
+
_read_attribute_without_safety(name)
|
19
|
+
else
|
20
|
+
raise ForbiddenColumnException, "Column #{name} is not allowed for access."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
alias_method_chain method, :safety
|
24
|
+
|
25
|
+
break
|
17
26
|
end
|
18
27
|
end
|
19
|
-
alias_method_chain :_read_attribute, :safety
|
20
28
|
end
|
21
29
|
|
22
30
|
module ClassMethods
|
data/lib/remote_db/version.rb
CHANGED
@@ -110,11 +110,11 @@ describe RemoteDb do
|
|
110
110
|
it 'should not allow accessing hidden columns' do
|
111
111
|
person = TestDb::Person.first
|
112
112
|
expect {
|
113
|
-
|
113
|
+
person.last_name
|
114
114
|
}.to raise_error(RemoteDb::Concerns::RestrictedColumns::ForbiddenColumnException)
|
115
115
|
|
116
116
|
expect {
|
117
|
-
|
117
|
+
person[:last_name]
|
118
118
|
}.to raise_error(RemoteDb::Concerns::RestrictedColumns::ForbiddenColumnException)
|
119
119
|
end
|
120
120
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Skalli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|