Class: Distyll
- Inherits:
-
Object
- Object
- Distyll
- Defined in:
- lib/distyll.rb
Instance Attribute Summary collapse
-
#base_models ⇒ Object
readonly
Returns the value of attribute base_models.
-
#created_since ⇒ Object
readonly
Returns the value of attribute created_since.
-
#model_profiles ⇒ Object
readonly
Returns the value of attribute model_profiles.
Instance Method Summary collapse
-
#initialize(bms, cs) ⇒ Distyll
constructor
A new instance of Distyll.
- #run ⇒ Object
Constructor Details
#initialize(bms, cs) ⇒ Distyll
5 6 7 8 9 |
# File 'lib/distyll.rb', line 5 def initialize(bms, cs) @created_since = cs.to_date @base_models = bms.map &:constantize set_model_profiles end |
Instance Attribute Details
#base_models ⇒ Object (readonly)
Returns the value of attribute base_models.
3 4 5 |
# File 'lib/distyll.rb', line 3 def base_models @base_models end |
#created_since ⇒ Object (readonly)
Returns the value of attribute created_since.
3 4 5 |
# File 'lib/distyll.rb', line 3 def created_since @created_since end |
#model_profiles ⇒ Object (readonly)
Returns the value of attribute model_profiles.
3 4 5 |
# File 'lib/distyll.rb', line 3 def model_profiles @model_profiles end |
Instance Method Details
#run ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/distyll.rb', line 11 def run base_models.each do |model| @model_profiles[model].(@created_since) end prior_count = -1 while prior_count != current_count prior_count = current_count @model_profiles.each_value &:demote_new_ids @model_profiles.each_value do |profile| profile.associations.each do |a| @model_profiles[a.klass].load_ids(profile.get_new_associated_ids(a)) end end end @model_profiles.each_value do |profile| profile.copy_records end end |