Module: ModelOrchestration::Persistence

Extended by:
ActiveSupport::Concern
Defined in:
lib/model_orchestration/persistence.rb

Overview

Including this module will give an OrchestrationModel::Base ActiveRecord-like methods for perstistence. The methods available are restricted to variations of save and create because updating/deleting/finding are usually actions performed on a single record, not an orchestrated meta model.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#save(*args) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/model_orchestration/persistence.rb', line 35

def save(*args)
  @nested_model_instances.each do |key, instance|
    return false unless instance.save(args)
  end

  true
end

#save!(*args) ⇒ Object



45
46
47
48
49
# File 'lib/model_orchestration/persistence.rb', line 45

def save!(*args)
  @nested_model_instances.each do |key, instance|
    instance.save(args)
  end
end