module ServiceOperation::Params::InstanceMethods
Private Instance Methods
attribute_exists?(method_name)
click to toggle source
# File lib/service_operation/params.rb, line 122 def attribute_exists?(method_name) self.class.attribute_names.include?(method_name) end
method_missing(method_name, *args, &block)
click to toggle source
delegate to context if calling an explicit param
Calls superclass method
# File lib/service_operation/params.rb, line 109 def method_missing(method_name, *args, &block) method_name_without_q = method_name.to_s.delete('?').to_sym if attribute_exists?(method_name_without_q) context.send(method_name_without_q, *args, &block) else super end end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/service_operation/params.rb, line 118 def respond_to_missing?(method_name, include_private = false) attribute_exists?(method_name) || super end
validate_attributes(attributes, coerce: false)
click to toggle source
# File lib/service_operation/params.rb, line 90 def validate_attributes(attributes, coerce: false) attributes.each do |attr| value = attr.optional ? context[attr.name] : send(attr.name) context[attr.name] = value = attr.from(value, self.class) if coerce if error = attr.error(value) errors.add(attr.name, error) end end context.fail!(errors: errors) if errors.any? end
validate_params()
click to toggle source
coerces param and adds an error if it fails to validate type
# File lib/service_operation/params.rb, line 82 def validate_params validate_attributes(self.class.params, coerce: true) end
validate_returns()
click to toggle source
# File lib/service_operation/params.rb, line 86 def validate_returns validate_attributes(self.class.returns) end