Sha256: 899ed5a7b5aa3c01cae72229c1fc37062c7fd014aa3636a384d6100e54df0adc
Contents?: true
Size: 848 Bytes
Versions: 59
Compression:
Stored size: 848 Bytes
Contents
# frozen_string_literal: true module Decidim module Admin # This form handles permissions for a particular action in the admin panel. class PermissionForm < Form attribute :authorization_handler_name, String attribute :options, String validate :sanitize validate :options_is_valid_json private def sanitize self.authorization_handler_name = nil if authorization_handler_name.blank? self.options = nil if authorization_handler_name.blank? self.options = nil if options.blank? end def options_is_valid_json return unless options result = JSON.parse(options) errors.add(:options, :invalid_json) unless result.is_a?(Hash) result rescue JSON::ParserError errors.add(:options, :invalid_json) end end end end
Version data entries
59 entries across 59 versions & 2 rubygems