Class: RailsMermaidErd::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails-mermaid_erd/configuration.rb

Constant Summary collapse

DEFAULTS =
{
  result_path: "mermaid_erd/index.html",
  ignore_tables: []
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rails-mermaid_erd/configuration.rb', line 11

def initialize
  config = DEFAULTS.dup

  config_file = Rails.root.join("config/mermaid_erd.yml")
  if File.exist?(config_file)
    # `safe_load` over `load` because this file is checked into the host
    # repo and may eventually be templated from CI inputs. Disallow custom
    # classes and aliases — the only legitimate value shapes here are
    # strings and arrays of strings.
    custom_config = YAML.safe_load(config_file.read, permitted_classes: [], aliases: false).symbolize_keys
    config = config.merge(custom_config)
  end

  @result_path = config[:result_path]
  @ignore_tables = normalize_ignore_tables(config[:ignore_tables])
end

Instance Attribute Details

#ignore_tablesObject

Returns the value of attribute ignore_tables.



4
5
6
# File 'lib/rails-mermaid_erd/configuration.rb', line 4

def ignore_tables
  @ignore_tables
end

#result_pathObject

Returns the value of attribute result_path.



4
5
6
# File 'lib/rails-mermaid_erd/configuration.rb', line 4

def result_path
  @result_path
end