class ActiveRecord::Encryption::AutoFilteredParameters
Attributes
app[R]
Public Class Methods
new(app)
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 6 def initialize(app) @app = app @attributes_by_class = Concurrent::Map.new @collecting = true install_collecting_hook end
Public Instance Methods
enable()
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 14 def enable apply_collected_attributes @collecting = false end
Private Instance Methods
apply_collected_attributes()
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 36 def apply_collected_attributes @attributes_by_class.each do |klass, attributes| attributes.each do |attribute| apply_filter(klass, attribute) end end end
apply_filter(klass, attribute)
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 53 def apply_filter(klass, attribute) filter = [("#{klass.model_name.element}" if klass.name), attribute.to_s].compact.join(".") unless excluded_from_filter_parameters?(filter) app.config.filter_parameters << filter unless app.config.filter_parameters.include?(filter) klass.filter_attributes += [ attribute ] end end
attribute_was_declared(klass, attribute)
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 28 def attribute_was_declared(klass, attribute) if collecting? collect_for_later(klass, attribute) else apply_filter(klass, attribute) end end
collect_for_later(klass, attribute)
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 48 def collect_for_later(klass, attribute) @attributes_by_class[klass] ||= Concurrent::Array.new @attributes_by_class[klass] << attribute end
collecting?()
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 44 def collecting? @collecting end
excluded_from_filter_parameters?(filter_parameter)
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 61 def excluded_from_filter_parameters?(filter_parameter) ActiveRecord::Encryption.config.excluded_from_filter_parameters.find { |excluded_filter| excluded_filter.to_s == filter_parameter } end
install_collecting_hook()
click to toggle source
# File lib/active_record/encryption/auto_filtered_parameters.rb, line 22 def install_collecting_hook ActiveRecord::Encryption.on_encrypted_attribute_declared do |klass, attribute| attribute_was_declared(klass, attribute) end end