Class: Penman::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/penman/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/penman/configuration.rb', line 10

def initialize
  @seed_path = 'db/migrate'
  @default_candidate_key = :reference

  root = File.expand_path '../..', __FILE__
  @seed_template_file = File.join(root, 'templates', 'default.rb.erb')

  @file_name_formatter = lambda do |model_name, seed_type|
    "#{model_name.underscore.pluralize}_#{seed_type}"
  end

  @after_generate = lambda do |version, name|
    return unless ActiveRecord::Base.connection.table_exists? 'schema_migrations'

    unless Object.const_defined?('SchemaMigration')
      Object.const_set('SchemaMigration', Class.new(ActiveRecord::Base))
    end

    return unless SchemaMigration.column_names.include? 'version'

    SchemaMigration.find_or_create_by(version: version)
  end

  @validate_records_before_seed_generation = false
end

Instance Attribute Details

#after_generateObject

Returns the value of attribute after_generate.



3
4
5
# File 'lib/penman/configuration.rb', line 3

def after_generate
  @after_generate
end

#default_candidate_keyObject

Returns the value of attribute default_candidate_key.



3
4
5
# File 'lib/penman/configuration.rb', line 3

def default_candidate_key
  @default_candidate_key
end

#file_name_formatterObject

Returns the value of attribute file_name_formatter.



3
4
5
# File 'lib/penman/configuration.rb', line 3

def file_name_formatter
  @file_name_formatter
end

#seed_pathObject

Returns the value of attribute seed_path.



3
4
5
# File 'lib/penman/configuration.rb', line 3

def seed_path
  @seed_path
end

#seed_template_fileObject

Returns the value of attribute seed_template_file.



3
4
5
# File 'lib/penman/configuration.rb', line 3

def seed_template_file
  @seed_template_file
end

#validate_records_before_seed_generationObject

Returns the value of attribute validate_records_before_seed_generation.



3
4
5
# File 'lib/penman/configuration.rb', line 3

def validate_records_before_seed_generation
  @validate_records_before_seed_generation
end