Class: Distyll

Inherits:
Object
  • Object
show all
Defined in:
lib/distyll.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_modelsObject (readonly)

Returns the value of attribute base_models.



3
4
5
# File 'lib/distyll.rb', line 3

def base_models
  @base_models
end

#created_sinceObject (readonly)

Returns the value of attribute created_since.



3
4
5
# File 'lib/distyll.rb', line 3

def created_since
  @created_since
end

#model_profilesObject (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

#runObject



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].load_ids_by_timestamp(@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