Class: EvilSeed::Configuration
- Inherits:
-
Object
- Object
- EvilSeed::Configuration
- Defined in:
- lib/evil_seed/configuration.rb,
lib/evil_seed/configuration/root.rb
Overview
This module holds configuration for creating dump: which models and their constraints
Defined Under Namespace
Classes: Root
Instance Attribute Summary collapse
-
#dont_nullify ⇒ Object
Returns the value of attribute dont_nullify.
-
#record_dumper_class ⇒ Object
Returns the value of attribute record_dumper_class.
-
#unscoped ⇒ Object
Returns the value of attribute unscoped.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#verbose_sql ⇒ Object
Returns the value of attribute verbose_sql.
Instance Method Summary collapse
- #anonymize(model_class, &block) ⇒ Object
- #customize(model_class, &block) ⇒ Object
-
#customizers ⇒ Hash{String => Array<#call>}
Customizer objects for every model.
- #ignore_columns(model_class, *columns) ⇒ Object
- #ignored_columns_for(model_class) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #root(model, *constraints) {|new_root| ... } ⇒ Object
- #roots ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 |
# File 'lib/evil_seed/configuration.rb', line 12 def initialize @record_dumper_class = RecordDumper @verbose = false @verbose_sql = false @unscoped = false @dont_nullify = false @ignored_columns = Hash.new { |h, k| h[k] = [] } end |
Instance Attribute Details
#dont_nullify ⇒ Object
Returns the value of attribute dont_nullify.
10 11 12 |
# File 'lib/evil_seed/configuration.rb', line 10 def dont_nullify @dont_nullify end |
#record_dumper_class ⇒ Object
Returns the value of attribute record_dumper_class.
10 11 12 |
# File 'lib/evil_seed/configuration.rb', line 10 def record_dumper_class @record_dumper_class end |
#unscoped ⇒ Object
Returns the value of attribute unscoped.
10 11 12 |
# File 'lib/evil_seed/configuration.rb', line 10 def unscoped @unscoped end |
#verbose ⇒ Object
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/evil_seed/configuration.rb', line 10 def verbose @verbose end |
#verbose_sql ⇒ Object
Returns the value of attribute verbose_sql.
10 11 12 |
# File 'lib/evil_seed/configuration.rb', line 10 def verbose_sql @verbose_sql end |
Instance Method Details
#anonymize(model_class, &block) ⇒ Object
36 37 38 39 |
# File 'lib/evil_seed/configuration.rb', line 36 def anonymize(model_class, &block) raise(ArgumentError, "You must provide block for #{__method__} method") unless block customizers[model_class.to_s] << Anonymizer.new(model_class, &block) end |
#customize(model_class, &block) ⇒ Object
31 32 33 34 |
# File 'lib/evil_seed/configuration.rb', line 31 def customize(model_class, &block) raise(ArgumentError, "You must provide block for #{__method__} method") unless block customizers[model_class.to_s] << ->(attrs) { attrs.tap(&block) } # Ensure that we're returning attrs from it end |
#customizers ⇒ Hash{String => Array<#call>}
Customizer objects for every model
47 48 49 |
# File 'lib/evil_seed/configuration.rb', line 47 def customizers @customizers ||= Hash.new { |h, k| h[k] = [] } end |
#ignore_columns(model_class, *columns) ⇒ Object
41 42 43 |
# File 'lib/evil_seed/configuration.rb', line 41 def ignore_columns(model_class, *columns) @ignored_columns[model_class.to_s] += columns.map(&:to_s) end |
#ignored_columns_for(model_class) ⇒ Object
51 52 53 |
# File 'lib/evil_seed/configuration.rb', line 51 def ignored_columns_for(model_class) @ignored_columns[model_class] end |
#root(model, *constraints) {|new_root| ... } ⇒ Object
25 26 27 28 29 |
# File 'lib/evil_seed/configuration.rb', line 25 def root(model, *constraints) new_root = Root.new(model, dont_nullify, *constraints) yield new_root if block_given? roots << new_root end |
#roots ⇒ Object
21 22 23 |
# File 'lib/evil_seed/configuration.rb', line 21 def roots @roots ||= [] end |