Class: Ratbug::GenerateConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ratbug/generate_config.rb

Constant Summary collapse

VALID_OPTION_KEYS =
%i[
    enabled_outputs
    ts_prefer_type
    ts_enum_output_type
    ts_prefer_undefined
    use_only_schema
    output_dir
    table_name_to_model_converter
    omit_timestamps
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ GenerateConfig

Returns a new instance of GenerateConfig.



19
20
21
22
23
24
# File 'lib/ratbug/generate_config.rb', line 19

def initialize(**options)
  @override_options = {}
  options.each do |key, value|
    set(key, value)
  end
end

Instance Attribute Details

#override_optionsObject

timestamp jbuilder indent usetab



17
18
19
# File 'lib/ratbug/generate_config.rb', line 17

def override_options
  @override_options
end

Instance Method Details

#optionsHash<Symbol, Object>

Returns:

  • (Hash<Symbol, Object>)


34
35
36
37
38
39
# File 'lib/ratbug/generate_config.rb', line 34

def options
  {
    **default_options,
    **@override_options
  }
end

#set(key, value) ⇒ Object



26
27
28
29
30
31
# File 'lib/ratbug/generate_config.rb', line 26

def set(key, value)
  key = key.to_sym
  puts "warning: GenerateConfig option #{key} has duplicated." unless @override_options[key].nil?
  @override_options[key] = value
  self
end