Class: EvilSeed::Configuration::Root
- Inherits:
-
Object
- Object
- EvilSeed::Configuration::Root
- Defined in:
- lib/evil_seed/configuration/root.rb
Overview
Configuration for dumping some root model and its associations
Instance Attribute Summary collapse
-
#association_limits ⇒ Object
readonly
Returns the value of attribute association_limits.
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#deep_limit ⇒ Object
readonly
Returns the value of attribute deep_limit.
-
#dont_nullify ⇒ Object
readonly
Returns the value of attribute dont_nullify.
-
#exclusions ⇒ Object
readonly
Returns the value of attribute exclusions.
-
#inclusions ⇒ Object
readonly
Returns the value of attribute inclusions.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#total_limit ⇒ Object
readonly
Returns the value of attribute total_limit.
Instance Method Summary collapse
- #do_not_nullify(nullify_flag) ⇒ Object
-
#exclude(*association_patterns) ⇒ Object
Exclude some of associations from the dump.
- #excluded?(association_path) ⇒ Boolean
-
#include(*association_patterns) ⇒ Object
Include some excluded associations back to the dump.
- #included?(association_path) ⇒ Boolean
-
#initialize(model, dont_nullify, *constraints) ⇒ Root
constructor
A new instance of Root.
-
#limit_associations_size(limit, association_pattern = nil) ⇒ Object
Limit number of records in all (if pattern is not provided) or given associations to include into dump.
-
#limit_deep(limit) ⇒ Object
Limit deepenes of associations to include into dump.
Constructor Details
#initialize(model, dont_nullify, *constraints) ⇒ Root
Returns a new instance of Root.
13 14 15 16 17 18 19 20 21 |
# File 'lib/evil_seed/configuration/root.rb', line 13 def initialize(model, dont_nullify, *constraints) @model = model @constraints = constraints @exclusions = [] @inclusions = [] @association_limits = {} @deep_limit = nil @dont_nullify = dont_nullify end |
Instance Attribute Details
#association_limits ⇒ Object (readonly)
Returns the value of attribute association_limits.
8 9 10 |
# File 'lib/evil_seed/configuration/root.rb', line 8 def association_limits @association_limits end |
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
7 8 9 |
# File 'lib/evil_seed/configuration/root.rb', line 7 def constraints @constraints end |
#deep_limit ⇒ Object (readonly)
Returns the value of attribute deep_limit.
8 9 10 |
# File 'lib/evil_seed/configuration/root.rb', line 8 def deep_limit @deep_limit end |
#dont_nullify ⇒ Object (readonly)
Returns the value of attribute dont_nullify.
8 9 10 |
# File 'lib/evil_seed/configuration/root.rb', line 8 def dont_nullify @dont_nullify end |
#exclusions ⇒ Object (readonly)
Returns the value of attribute exclusions.
9 10 11 |
# File 'lib/evil_seed/configuration/root.rb', line 9 def exclusions @exclusions end |
#inclusions ⇒ Object (readonly)
Returns the value of attribute inclusions.
9 10 11 |
# File 'lib/evil_seed/configuration/root.rb', line 9 def inclusions @inclusions end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
7 8 9 |
# File 'lib/evil_seed/configuration/root.rb', line 7 def model @model end |
#total_limit ⇒ Object (readonly)
Returns the value of attribute total_limit.
8 9 10 |
# File 'lib/evil_seed/configuration/root.rb', line 8 def total_limit @total_limit end |
Instance Method Details
#do_not_nullify(nullify_flag) ⇒ Object
52 53 54 |
# File 'lib/evil_seed/configuration/root.rb', line 52 def do_not_nullify(nullify_flag) @dont_nullify = nullify_flag end |
#exclude(*association_patterns) ⇒ Object
Exclude some of associations from the dump
25 26 27 |
# File 'lib/evil_seed/configuration/root.rb', line 25 def exclude(*association_patterns) @exclusions += association_patterns end |
#excluded?(association_path) ⇒ Boolean
56 57 58 |
# File 'lib/evil_seed/configuration/root.rb', line 56 def excluded?(association_path) exclusions.any? { |exclusion| association_path.match(exclusion) } #.match(association_path) } end |
#include(*association_patterns) ⇒ Object
Include some excluded associations back to the dump
31 32 33 |
# File 'lib/evil_seed/configuration/root.rb', line 31 def include(*association_patterns) @inclusions += association_patterns end |
#included?(association_path) ⇒ Boolean
60 61 62 |
# File 'lib/evil_seed/configuration/root.rb', line 60 def included?(association_path) inclusions.any? { |inclusion| association_path.match(inclusion) } #.match(association_path) } end |
#limit_associations_size(limit, association_pattern = nil) ⇒ Object
Limit number of records in all (if pattern is not provided) or given associations to include into dump
38 39 40 41 42 43 44 |
# File 'lib/evil_seed/configuration/root.rb', line 38 def limit_associations_size(limit, association_pattern = nil) if association_pattern @association_limits[association_pattern] = limit else @total_limit = limit end end |
#limit_deep(limit) ⇒ Object
Limit deepenes of associations to include into dump
48 49 50 |
# File 'lib/evil_seed/configuration/root.rb', line 48 def limit_deep(limit) @deep_limit = limit end |