Class: EvilSeed::RootDumper
- Inherits:
-
Object
- Object
- EvilSeed::RootDumper
- Defined in:
- lib/evil_seed/root_dumper.rb
Overview
This module collects dumps generation for root and all it’s dependencies
Instance Attribute Summary collapse
-
#association_limits ⇒ Object
readonly
Returns the value of attribute association_limits.
-
#deep_limit ⇒ Object
readonly
Returns the value of attribute deep_limit.
-
#dont_nullify ⇒ Object
readonly
Returns the value of attribute dont_nullify.
-
#dumper ⇒ Object
readonly
Returns the value of attribute dumper.
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#total_limit ⇒ Object
readonly
Returns the value of attribute total_limit.
Instance Method Summary collapse
-
#call ⇒ Object
Generate dump and write it into
io
. -
#check_limits!(association_path) ⇒ Boolean
true
if limits are NOT reached andfalse
otherwise. -
#initialize(root, dumper) ⇒ RootDumper
constructor
A new instance of RootDumper.
Constructor Details
#initialize(root, dumper) ⇒ RootDumper
Returns a new instance of RootDumper.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/evil_seed/root_dumper.rb', line 12 def initialize(root, dumper) @root = root @dumper = dumper @to_load_map = {} @total_limit = root.total_limit @deep_limit = root.deep_limit @dont_nullify = root.dont_nullify @association_limits = root.association_limits.dup @model_class = root.model.constantize end |
Instance Attribute Details
#association_limits ⇒ Object (readonly)
Returns the value of attribute association_limits.
8 9 10 |
# File 'lib/evil_seed/root_dumper.rb', line 8 def association_limits @association_limits end |
#deep_limit ⇒ Object (readonly)
Returns the value of attribute deep_limit.
8 9 10 |
# File 'lib/evil_seed/root_dumper.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/root_dumper.rb', line 8 def dont_nullify @dont_nullify end |
#dumper ⇒ Object (readonly)
Returns the value of attribute dumper.
8 9 10 |
# File 'lib/evil_seed/root_dumper.rb', line 8 def dumper @dumper end |
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
8 9 10 |
# File 'lib/evil_seed/root_dumper.rb', line 8 def model_class @model_class end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/evil_seed/root_dumper.rb', line 8 def root @root end |
#total_limit ⇒ Object (readonly)
Returns the value of attribute total_limit.
8 9 10 |
# File 'lib/evil_seed/root_dumper.rb', line 8 def total_limit @total_limit end |
Instance Method Details
#call ⇒ Object
Generate dump and write it into io
26 27 28 29 30 31 32 |
# File 'lib/evil_seed/root_dumper.rb', line 26 def call association_path = model_class.model_name.singular relation = model_class.all relation = relation.unscoped if configuration.unscoped relation = relation.where(*root.constraints) if root.constraints.any? # without arguments returns not a relation RelationDumper.new(relation, self, association_path).call end |
#check_limits!(association_path) ⇒ Boolean
Returns true
if limits are NOT reached and false
otherwise.
35 36 37 |
# File 'lib/evil_seed/root_dumper.rb', line 35 def check_limits!(association_path) check_total_limit! && check_association_limits!(association_path) end |