Module: Yogo::Collection::Data::ModelConfiguration

Included in:
Yogo::Collection::Data
Defined in:
lib/yogo/collection/data/model_configuration.rb

Instance Method Summary collapse

Instance Method Details

#after_model_generate(model) ⇒ Object



8
9
10
11
12
13
# File 'lib/yogo/collection/data/model_configuration.rb', line 8

def after_model_generate(model)
  model = super
  model.extend(Data::Model)
  model.send(:include, Data::Model::InstanceMethods)
  model
end

#after_model_update(model) ⇒ Object



34
35
36
37
38
# File 'lib/yogo/collection/data/model_configuration.rb', line 34

def after_model_update(model)
  model.extend(Data::ModelProperties)
  model.auto_upgrade!
  model
end

#before_model_update(model) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/yogo/collection/data/model_configuration.rb', line 15

def before_model_update(model)
  model = super
  model.properties.clear
  model.properties.instance_variable_get(:@properties).clear #clear out the name index
  # Need to remove relationships too
  model.relationships.clear
  model.validators.clear!
  model
end

#model_update(model) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/yogo/collection/data/model_configuration.rb', line 25

def model_update(model)
  model = super
  schema.reload
  schema.each do |field|
    field.add_to_model(model)
  end
  model
end