Class: TableStructure::Schema::Table::KeyDecorator

Inherits:
Object
  • Object
show all
Defined in:
lib/table_structure/schema/table/key_decorator.rb

Instance Method Summary collapse

Constructor Details

#initialize(prefix: nil, suffix: nil) ⇒ KeyDecorator

Returns a new instance of KeyDecorator.



7
8
9
10
# File 'lib/table_structure/schema/table/key_decorator.rb', line 7

def initialize(prefix: nil, suffix: nil)
  @prefix = prefix
  @suffix = suffix
end

Instance Method Details

#decorate(keys) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/table_structure/schema/table/key_decorator.rb', line 12

def decorate(keys)
  return keys unless has_any_options?

  keys.map do |key|
    next key unless key

    decorated_key = "#{@prefix}#{key}#{@suffix}"
    decorated_key = decorated_key.to_sym if key.is_a?(Symbol)
    decorated_key
  end
end