class Ratbug::GenerateConfig

Constants

VALID_OPTION_KEYS

Attributes

override_options[RW]

timestamp jbuilder indent usetab

Public Class Methods

new(**options) click to toggle source
# File lib/ratbug/generate_config.rb, line 19
def initialize(**options)
  @override_options = {}
  options.each do |key, value|
    set(key, value)
  end
end

Public Instance Methods

options() click to toggle source

@return [Hash<Symbol, Object>]

# File lib/ratbug/generate_config.rb, line 34
def options
  {
    **default_options,
    **@override_options
  }
end
set(key, value) click to toggle source
# 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

Private Instance Methods

default_options() click to toggle source

@return [Hash<Symbol, Object>]

# File lib/ratbug/generate_config.rb, line 44
def default_options
  {
    enabled_outputs: ['jbuilder', 'typescript'],
    ts_prefer_type: true, # type or interface
    ts_enum_output: 'union_type', # 'enum'
    ts_prefere_undefined: true, # or null
    use_only_schema: false, # scan model files
    output_dir: Rails.root.join('tmp', 'ratbug'),
    table_name_to_model_converter: -> table_name { table_name.singularize.camelize.constantize },
    omit_timestamps: true
  }
end