Class: AccessFilter
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AccessFilter
- Defined in:
- app/models/access_filter.rb
Overview
NOTE: mark user values with “$user.<attribute>$”, e.g. “$user.bfsnr$”
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.user_value(user, value) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/access_filter.rb', line 25 def self.user_value(user, value) # replace "$user.<attribute>$" placeholders with user.app_infos[<attribute>] values user_attributes = value.to_s.scan(/\$user\.(\w+)\$/).flatten unless user_attributes.empty? if user.nil? # empty values if no user value.sub(/\$user\.(\w+)\$/, '') else user_attributes.each do |key| # replace placeholder with value from user.app_infos value.sub!(/\$user\.#{key}\$/, user.app_infos[key] || '') end value end else value end end |
Instance Method Details
#parse_condition ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/access_filter.rb', line 10 def parse_condition if ["WMS", "WFS"].include?(resource_type) wms_condition = condition begin # try to parse as JSON wms_condition = JSON.parse(wms_condition) rescue => err Rails.logger.info "Could not parse #{resource_type} condition for #{role.name} #{resource} as JSON: #{err}" end wms_condition else condition end end |