rails_admin_authorized_fields 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c5f689eb215e23c32040ec7ba8d4a5ce07a04f50
4
- data.tar.gz: 1b08c610512755382f5f1e6106e0a856576a9262
3
+ metadata.gz: c3ddbd9ec37f940016aa0799032308491c2ef5c2
4
+ data.tar.gz: b11092e3da381667a0dc27ed25479bf09fb67983
5
5
  SHA512:
6
- metadata.gz: fd454bdbaeb59390460647955ccf2143ee5ad6b90b23559cca7f62cf55a30120477d074179021e7692cb793f1ead722b2fc857659a9d00a98120abc0c5d350ba
7
- data.tar.gz: 593a67d5a1b0415fb2e68dd5bfeeaea3edf41bf9488798984907f0ed7b17b4ea9bd75e46f620c051638ecc90fbb8da9db3ea3298121caa4fdbcd77d37abbbf15
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
+
@@ -1,3 +1,3 @@
1
1
  module RailsAdminAuthorizedFields
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-20 00:00:00.000000000 Z
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