rails_admin_authorized_fields 0.0.1 → 0.0.2
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/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/lib/rails_admin_authorized_fields/section.rb +55 -0
- data/lib/rails_admin_authorized_fields/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3ddbd9ec37f940016aa0799032308491c2ef5c2
|
4
|
+
data.tar.gz: b11092e3da381667a0dc27ed25479bf09fb67983
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cb18ccf2c9a8447ed2455edf65984ca58dde5c8931d7b39703009ec7e02b751e401c8aa76143d21a82fa702de3911303701335c702b213d65ca7e91a477e09b
|
7
|
+
data.tar.gz: b922e774c0be83c01db94457424e6cc37b0c48c7f574ec3b24e1b3839b12e74b51f81629a0e449b3a1db8ffed5b5861496c6ea012a0ca947e41a45d29a6ad3ef
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rails_admin_authorized_fields
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.2
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module RailsAdminAuthorizedFields
|
2
|
+
module AuthorazedFieldsSection
|
3
|
+
attr_accessor :authorization_rules
|
4
|
+
|
5
|
+
def initialize(parent)
|
6
|
+
@authorization_rules = {}
|
7
|
+
|
8
|
+
super(parent)
|
9
|
+
end
|
10
|
+
|
11
|
+
def authorized_fields(rules)
|
12
|
+
rules.each do |fields, rule|
|
13
|
+
fields = [ fields ].flatten
|
14
|
+
|
15
|
+
fields.each do |name|
|
16
|
+
name = name.to_sym
|
17
|
+
@authorization_rules[ name ] ||= []
|
18
|
+
@authorization_rules[ name ] << rule
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def field_authorization_rules( name )
|
24
|
+
return @authorization_rules[ name ] || [] if @authorization_rules.any?
|
25
|
+
return [] if self.parent.nil?
|
26
|
+
parent.field_authorization_rules( name )
|
27
|
+
end
|
28
|
+
|
29
|
+
def visible_fields
|
30
|
+
super.select do |field|
|
31
|
+
authorized = true
|
32
|
+
|
33
|
+
rules = field.section.field_authorization_rules( field.name )
|
34
|
+
|
35
|
+
rules.each do |rule|
|
36
|
+
authorized &= instance_eval( &rule )
|
37
|
+
end
|
38
|
+
|
39
|
+
authorized
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
module RailsAdmin
|
46
|
+
module Config
|
47
|
+
module Sections
|
48
|
+
# Configuration of the show view for a new object
|
49
|
+
class Base
|
50
|
+
prepend RailsAdminAuthorizedFields::AuthorazedFieldsSection
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_authorized_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Malykh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails_admin
|
@@ -60,11 +60,14 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
|
+
- ".ruby-gemset"
|
64
|
+
- ".ruby-version"
|
63
65
|
- Gemfile
|
64
66
|
- LICENSE.txt
|
65
67
|
- README.md
|
66
68
|
- Rakefile
|
67
69
|
- lib/rails_admin_authorized_fields.rb
|
70
|
+
- lib/rails_admin_authorized_fields/section.rb
|
68
71
|
- lib/rails_admin_authorized_fields/version.rb
|
69
72
|
- rails_admin_authorized_fields.gemspec
|
70
73
|
homepage: https://github.com/xronos-i-am/rails_admin_authorized_fields
|