Module: Trailblazer::V1_1::Operation::Setup

Included in:
Trailblazer::V1_1::Operation
Defined in:
lib/trailblazer/1.1/operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#model=(value) ⇒ Object (writeonly)

Sets the attribute model

Parameters:

  • value

    the value to set the attribute model to.



91
92
93
# File 'lib/trailblazer/1.1/operation.rb', line 91

def model=(value)
  @model = value
end

Instance Method Details

#assign_model!(*args) ⇒ Object



119
120
121
# File 'lib/trailblazer/1.1/operation.rb', line 119

def assign_model!(*args)
  @model = model!(*args)
end

#assign_params!(params) ⇒ Object



100
101
102
# File 'lib/trailblazer/1.1/operation.rb', line 100

def assign_params!(params)
  @params = params!(params)
end

#build_model!(*args) ⇒ Object



114
115
116
117
# File 'lib/trailblazer/1.1/operation.rb', line 114

def build_model!(*args)
  assign_model!(*args) # @model = ..
  setup_model!(*args)
end

#model!(params) ⇒ Object

Implement #model! to find/create your operation model (if required).



124
125
# File 'lib/trailblazer/1.1/operation.rb', line 124

def model!(params)
end

#params!(params) ⇒ Object

Overwrite #params! if you need to change its structure, by returning a new params object from this method. This is helpful if you don’t want to change the original via #setup_params!.



107
108
109
# File 'lib/trailblazer/1.1/operation.rb', line 107

def params!(params)
  params
end

#setup!(params) ⇒ Object



93
94
95
96
97
98
# File 'lib/trailblazer/1.1/operation.rb', line 93

def setup!(params)
  params = assign_params!(params)
  setup_params!(params)
  build_model!(params)
  params # TODO: test me.
end

#setup_model!(params) ⇒ Object

Override to add attributes that can be infered from params.



128
129
# File 'lib/trailblazer/1.1/operation.rb', line 128

def setup_model!(params)
end

#setup_params!(params) ⇒ Object



111
112
# File 'lib/trailblazer/1.1/operation.rb', line 111

def setup_params!(params)
end