Class: ActiveRecord::DataClassification::ModelReflection
- Inherits:
-
Object
- Object
- ActiveRecord::DataClassification::ModelReflection
- Includes:
- Aggregate::Extension
- Defined in:
- lib/active_record/data_classification/model_reflection.rb
Constant Summary
Constants included from Aggregate::Extension
Aggregate::Extension::AGGREGATE_BUILTINS
Instance Attribute Summary collapse
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#server_type ⇒ Object
readonly
Returns the value of attribute server_type.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #columns ⇒ Object
-
#initialize(table_name, models) ⇒ ModelReflection
constructor
A new instance of ModelReflection.
Constructor Details
#initialize(table_name, models) ⇒ ModelReflection
Returns a new instance of ModelReflection.
8 9 10 11 12 13 14 15 16 |
# File 'lib/active_record/data_classification/model_reflection.rb', line 8 def initialize(table_name, models) @models = models @model = @models.find { |m| m.try(:base_class) == m } || @models.first @server_type = find_server_type(table_name) @model_name = @model.name @table_name = table_name end |
Instance Attribute Details
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
6 7 8 |
# File 'lib/active_record/data_classification/model_reflection.rb', line 6 def model_name @model_name end |
#server_type ⇒ Object (readonly)
Returns the value of attribute server_type.
6 7 8 |
# File 'lib/active_record/data_classification/model_reflection.rb', line 6 def server_type @server_type end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
6 7 8 |
# File 'lib/active_record/data_classification/model_reflection.rb', line 6 def table_name @table_name end |
Instance Method Details
#columns ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/active_record/data_classification/model_reflection.rb', line 18 def columns connection.columns(table_name).map do |column| column_spec = @model.try(:field_specs)&.[](column.name) Column.new( column.name, column.sql_type, sensitivity_friendly(@models, column_spec&.data_security), sensitivity_source(@models, column_spec&.data_security), anonymization_type || column_spec&.anonymize_using, @models ) end end |