Sha256: d52213f1200c903ec7b4f73e11f01d7f4e12677e26680567e26925b8387e45b4

Contents?: true

Size: 1.13 KB

Versions: 27

Compression:

Stored size: 1.13 KB

Contents

module Foobara
  module BuiltinTypes
    module Entity
      module Validators
        class AttributesDeclaration < Model::Validators::AttributesDeclaration
          def applicable?(record)
            record.created? || record.built?
          end

          # Why is this here in entity/ instead of in model/?
          def possible_errors
            return [] if parent_declaration_data == { type: :entity }

            mutable = parent_declaration_data.key?(:mutable) ? parent_declaration_data[:mutable] : false

            if parent_declaration_data.key?(:model_class)
              Object.const_get(parent_declaration_data[:model_class]).possible_errors(mutable:)
            elsif parent_declaration_data[:type] != :entity
              model_type = type_for_declaration(parent_declaration_data[:type])
              model_class = model_type.target_class
              model_class.possible_errors(mutable:)
            else
              # :nocov:
              raise "Missing :model_class in parent_declaration_data for #{parent_declaration_data}"
              # :nocov:
            end
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.6 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.5 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.4 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.3 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.2 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.1 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb