Class: Masking::Config::TargetColumns::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/masking/config/target_columns/column.rb

Defined Under Namespace

Classes: ColumnNameIsNil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, table_name:, method_value:) ⇒ Column

Returns a new instance of Column.

Raises:



11
12
13
14
15
16
17
18
# File 'lib/masking/config/target_columns/column.rb', line 11

def initialize(name, table_name:, method_value:)
  raise ColumnNameIsNil if name.nil?

  @original_name = name.to_sym
  @table_name    = table_name.to_sym
  @method_value  = method_value
  @method        = Method.new(method_value, ignore_null: ignore_null?)
end

Instance Attribute Details

#methodObject (readonly)

Returns the value of attribute method.



9
10
11
# File 'lib/masking/config/target_columns/column.rb', line 9

def method
  @method
end

#method_valueObject (readonly)

Returns the value of attribute method_value.



9
10
11
# File 'lib/masking/config/target_columns/column.rb', line 9

def method_value
  @method_value
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



9
10
11
# File 'lib/masking/config/target_columns/column.rb', line 9

def table_name
  @table_name
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/masking/config/target_columns/column.rb', line 20

def ==(other)
  name == other.name && table_name == other.table_name && method_value == other.method_value
end

#ignore_null?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/masking/config/target_columns/column.rb', line 28

def ignore_null?
  @ignore_null ||= original_name.to_s.end_with?(IGNORE_NULL_SUFFIX)
end

#nameObject



24
25
26
# File 'lib/masking/config/target_columns/column.rb', line 24

def name
  @name ||= ignore_null? ? original_name.to_s.chomp(IGNORE_NULL_SUFFIX).to_sym : original_name
end