class J2119::AllowedFields
Public Class Methods
new()
click to toggle source
# File lib/j2119/allowed_fields.rb, line 20 def initialize @allowed = {} @any = [] end
Public Instance Methods
allowed?(roles, child)
click to toggle source
# File lib/j2119/allowed_fields.rb, line 34 def allowed?(roles, child) any?(roles) || roles.any? do |role| @allowed[role] && @allowed[role].include?(child) end end
any?(roles)
click to toggle source
# File lib/j2119/allowed_fields.rb, line 40 def any?(roles) roles.any? do |role| @any.include?(role) end end
set_allowed(role, child)
click to toggle source
# File lib/j2119/allowed_fields.rb, line 25 def set_allowed(role, child) @allowed[role] ||= [] @allowed[role] << child end
set_any(role)
click to toggle source
# File lib/j2119/allowed_fields.rb, line 30 def set_any(role) @any << role end