Class: Trailblazer::Operation::Model::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/operation/model.rb

Instance Method Summary collapse

Instance Method Details

#call(options, params) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/trailblazer/operation/model.rb', line 24

def call(options, params)
  deprecate_update!(options)
  action      = options["model.action"] || :new
  model_class = options["model.class"]

  send("#{action}!", model_class, params)
end

#find!(model_class, params) ⇒ Object



36
37
38
# File 'lib/trailblazer/operation/model.rb', line 36

def find!(model_class, params)
  model_class.find(params[:id])
end

#find_by!(model_class, params) ⇒ Object

Doesn’t throw an exception and will return false to divert to Left.



41
42
43
# File 'lib/trailblazer/operation/model.rb', line 41

def find_by!(model_class, params)
  model_class.find_by(id: params[:id])
end

#new!(model_class, params) ⇒ Object



32
33
34
# File 'lib/trailblazer/operation/model.rb', line 32

def new!(model_class, params)
  model_class.new
end