Module: RailsAdminAuthorizedFields::AuthorazedFieldsSection
- Included in:
- RailsAdmin::Config::Sections::Base
- Defined in:
- lib/rails_admin_authorized_fields/section.rb
Instance Method Summary collapse
- #authorized_fields(rules) ⇒ Object
- #initialize(parent) ⇒ Object
- #unauthorized_fields(rules) ⇒ Object
- #visible_fields ⇒ Object
Instance Method Details
#authorized_fields(rules) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rails_admin_authorized_fields/section.rb', line 9 def (rules) rules.each do |fields, rule| fields = [fields].flatten fields.each do |name| name = name.to_sym @allow_rules[name] ||= [] @allow_rules[name] << rule end end end |
#initialize(parent) ⇒ Object
3 4 5 6 7 |
# File 'lib/rails_admin_authorized_fields/section.rb', line 3 def initialize(parent) @allow_rules, @deny_rules = {}, {} super(parent) end |
#unauthorized_fields(rules) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rails_admin_authorized_fields/section.rb', line 21 def (rules) rules.each do |fields, rule| fields = [fields].flatten fields.each do |name| name = name.to_sym @deny_rules[name] ||= [] @deny_rules[name] << rule end end end |
#visible_fields ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rails_admin_authorized_fields/section.rb', line 33 def visible_fields return super if bindings.nil? super.select do |field| = true rules = field.section.(field.name) rules[:allow].each do |rule| &= instance_eval(&rule) end rules[:deny].each do |rule| &= !instance_eval(&rule) end end end |