Module: Sandwich::Model::Machinist

Includes:
Base
Defined in:
lib/sandwich/model/machinist.rb

Defined Under Namespace

Modules: Extensions Classes: Materializer

Instance Method Summary collapse

Methods included from Base

#definition, #materialize!

Instance Method Details

#record(name, args) ⇒ Object

Raises:



99
100
101
102
103
104
105
# File 'lib/sandwich/model/machinist.rb', line 99

def record(name, args)
  materializer = Materializer[name]

  raise ModelNotFoundError, "No model found for '#{name}'" if materializer.nil?

  materializer.get(args)
end

#record!(name, args) ⇒ Object

Create a record

Raises:



91
92
93
94
95
96
97
# File 'lib/sandwich/model/machinist.rb', line 91

def record!(name, args)
  materializer = Materializer[name]

  raise ModelNotFoundError, "No model found for '#{name}'" if materializer.nil?
  
  materializer.create(args)
end