Module: BusinessFlow::DSL
- Defined in:
- lib/business_flow/dsl.rb
Overview
Core DSL for BusinessFlow. The relevant methods are all in ClassMethods.
Defined Under Namespace
Modules: ClassMethods, ErrorSupport
Classes: Field, FieldList, MemoizedField, ParameterField, ParameterObject, PublicField, UsesField
Constant Summary
collapse
- RESULT_DEF =
%(
class Result
def initialize(errors)
@errors = errors
end
def errors
@errors ||= ActiveModel::Errors.new(self)
end
def errors?
# We're explicitly using the instance variable here so that if no
# errors have been created, we don't initialize the error object.
@errors.present?
end
def valid?(_context = nil)
# We're explicitly using the instance variable here so that if no
# errors have been created, we don't initialize the error object.
@errors.blank?
end
def invalid?(context = nil)
!valid?(context)
end
end
).freeze
Class Method Summary
collapse
-
.included(klass) ⇒ Object
:reek:ManualDispatch I have no need to actually call human_attribute_name, I just need to know if I have to provide my own.
Instance Method Summary
collapse
Class Method Details
.included(klass) ⇒ Object
:reek:ManualDispatch I have no need to actually call human_attribute_name, I just need to know if I have to provide my own.
165
166
167
168
169
|
# File 'lib/business_flow/dsl.rb', line 165
def self.included(klass)
klass.extend(ClassMethods)
klass.class_eval RESULT_DEF, __FILE__, __LINE__
klass.extend(ErrorSupport) unless klass.respond_to?(:human_attribute_name)
end
|
Instance Method Details
#call ⇒ Object
174
175
176
177
178
|
# File 'lib/business_flow/dsl.rb', line 174
def call
return if invalid?
klass = self.class
klass.step_executor.new(klass.step_queue, self).call
end
|
#errors ⇒ Object
195
196
197
|
# File 'lib/business_flow/dsl.rb', line 195
def errors
@errors ||= ActiveModel::Errors.new(self)
end
|
#errors? ⇒ Boolean
199
200
201
202
203
|
# File 'lib/business_flow/dsl.rb', line 199
def errors?
@errors.present?
end
|
#invalid?(context = nil) ⇒ Boolean
211
212
213
|
# File 'lib/business_flow/dsl.rb', line 211
def invalid?(context = nil)
!valid?(context)
end
|
#valid?(_context = nil) ⇒ Boolean
205
206
207
208
209
|
# File 'lib/business_flow/dsl.rb', line 205
def valid?(_context = nil)
@errors.blank?
end
|