Class: PiiSafeSchema::PiiColumn
- Inherits:
-
Object
- Object
- PiiSafeSchema::PiiColumn
- Extended by:
- Annotations
- Defined in:
- lib/pii_safe_schema/pii_column.rb
Constant Summary
Constants included from Annotations
Annotations::COLUMNS, Annotations::SENSITIVE_DATA_NAMES
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#suggestion ⇒ Object
readonly
Returns the value of attribute suggestion.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(table:, column:, suggestion:) ⇒ PiiColumn
constructor
A new instance of PiiColumn.
Methods included from Annotations
apply_encrypted_recommendation?, apply_recommendation?, comment, encrypted?, recommended_comment
Constructor Details
#initialize(table:, column:, suggestion:) ⇒ PiiColumn
Returns a new instance of PiiColumn.
6 7 8 9 10 |
# File 'lib/pii_safe_schema/pii_column.rb', line 6 def initialize(table:, column:, suggestion:) @table = table.to_sym @column = column @suggestion = suggestion end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
4 5 6 |
# File 'lib/pii_safe_schema/pii_column.rb', line 4 def column @column end |
#suggestion ⇒ Object (readonly)
Returns the value of attribute suggestion.
4 5 6 |
# File 'lib/pii_safe_schema/pii_column.rb', line 4 def suggestion @suggestion end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
4 5 6 |
# File 'lib/pii_safe_schema/pii_column.rb', line 4 def table @table end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/pii_safe_schema/pii_column.rb', line 13 def all find_and_create end |
.from_column_name(table:, column:, suggestion:) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/pii_safe_schema/pii_column.rb', line 17 def from_column_name(table:, column:, suggestion:) activerecord_column = connection.columns(table.to_s).find { |c| c.name == column.to_s } unless activerecord_column raise InvalidColumnError, "column \"#{column}\" does not exist for table \"#{table}\"" end new(table: table, column: activerecord_column, suggestion: suggestion) end |