Module: RubySlime::Command

Extended by:
ActiveSupport::Concern, Forwardable
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
lib/ruby_slime/command.rb

Instance Method Summary collapse

Instance Method Details

#validated_attributesObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_slime/command.rb', line 20

def validated_attributes
  @validated_attributes__immutable_cache ||= begin
    normalized = attributes.compact
    schema = self.class._applied_schema
    return normalized unless schema
    result = schema.call(normalized)
    raise SchemaViolation.new(result.errors) unless result.success?
    result.to_h
  end
end