class Aggregates::DomainObject
Defines an object that is an element of the domain.
Public Class Methods
json_create(arguments)
click to toggle source
# File lib/aggregates/domain_object.rb, line 19 def self.json_create(arguments) new(**arguments) end
Public Instance Methods
to_json(*args)
click to toggle source
# File lib/aggregates/domain_object.rb, line 14 def to_json(*args) json_data = attributes.merge({ JSON.create_id => self.class.name }) json_data.to_json(*args) end
Protected Instance Methods
add_nested_errors_for(attribute, other_validator)
click to toggle source
# File lib/aggregates/domain_object.rb, line 25 def add_nested_errors_for(attribute, other_validator) nested_errors = other_validator.errors errors.messages[attribute] = nested_errors.messages errors.details[attribute] = nested_errors.details end
validate_nested_fields()
click to toggle source
# File lib/aggregates/domain_object.rb, line 31 def validate_nested_fields attributes.each do |key, value| add_nested_errors_for(key.to_sym, value) if value.is_a?(DomainObject) && !value.valid? end end