Class: Penman::Configuration
- Inherits:
-
Object
- Object
- Penman::Configuration
- Defined in:
- lib/penman/configuration.rb
Instance Attribute Summary collapse
-
#after_generate ⇒ Object
Returns the value of attribute after_generate.
-
#default_candidate_key ⇒ Object
Returns the value of attribute default_candidate_key.
-
#file_name_formatter ⇒ Object
Returns the value of attribute file_name_formatter.
-
#seed_path ⇒ Object
Returns the value of attribute seed_path.
-
#seed_template_file ⇒ Object
Returns the value of attribute seed_template_file.
-
#validate_records_before_seed_generation ⇒ Object
Returns the value of attribute validate_records_before_seed_generation.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
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. '../..', __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_generate ⇒ Object
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_key ⇒ Object
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_formatter ⇒ Object
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_path ⇒ Object
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_file ⇒ Object
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_generation ⇒ Object
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 |