class ViewModel::ActiveRecord

def load(scope: nil, eager_include: true, lock: nil)

# TODO: is this too much of a encapsulation violation?
# Load instances of the viewmodel by scope
def load(scope: nil, eager_include: true, lock: nil)
  load_scope = self.model_class.all
  load_scope = load_scope.lock(lock) if lock
  load_scope = load_scope.merge(scope) if scope
  vms = load_scope.map { |model| self.new(model) }
  ViewModel.preload_for_serialization(vms, lock: lock) if eager_include
  vms
end