Class: SchemaFerry::Config::TableRule

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_ferry/config.rb

Overview

Vocabulary available inside a table :name do ... end block.

Constant Summary collapse

EMPTY =

Null object for tables without a table ... do block.

new("").freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table_name) ⇒ TableRule

Returns a new instance of TableRule.



83
84
85
86
87
88
89
# File 'lib/schema_ferry/config.rb', line 83

def initialize(table_name)
  @table_name               = table_name.to_s
  @column_type_overrides    = {}
  @column_default_overrides = {}
  @ignored_columns          = []
  @ignored_indexes          = []
end

Instance Attribute Details

#column_default_overridesObject (readonly)

Returns the value of attribute column_default_overrides.



80
81
82
# File 'lib/schema_ferry/config.rb', line 80

def column_default_overrides
  @column_default_overrides
end

#column_type_overridesObject (readonly)

Returns the value of attribute column_type_overrides.



80
81
82
# File 'lib/schema_ferry/config.rb', line 80

def column_type_overrides
  @column_type_overrides
end

#ignored_columnsObject (readonly)

Returns the value of attribute ignored_columns.



80
81
82
# File 'lib/schema_ferry/config.rb', line 80

def ignored_columns
  @ignored_columns
end

#ignored_indexesObject (readonly)

Returns the value of attribute ignored_indexes.



80
81
82
# File 'lib/schema_ferry/config.rb', line 80

def ignored_indexes
  @ignored_indexes
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



80
81
82
# File 'lib/schema_ferry/config.rb', line 80

def table_name
  @table_name
end

Instance Method Details

#column(column_name, map_type_to:, default: DEFAULT_OMITTED) ⇒ Object



95
96
97
98
# File 'lib/schema_ferry/config.rb', line 95

def column(column_name, map_type_to:, default: DEFAULT_OMITTED)
  @column_type_overrides[column_name.to_s] = map_type_to.to_sym
  @column_default_overrides[column_name.to_s] = default unless default.equal?(DEFAULT_OMITTED)
end

#ignore_column(column_name) ⇒ Object



100
101
102
# File 'lib/schema_ferry/config.rb', line 100

def ignore_column(column_name)
  @ignored_columns << column_name.to_s
end

#ignore_index(index_name) ⇒ Object



104
105
106
# File 'lib/schema_ferry/config.rb', line 104

def ignore_index(index_name)
  @ignored_indexes << index_name.to_s
end