Sha256: d52213f1200c903ec7b4f73e11f01d7f4e12677e26680567e26925b8387e45b4

Contents?: true

Size: 1.13 KB

Versions: 26

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

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.25 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.24 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.23 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.22 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.21 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.20 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.19 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.18 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.17 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.16 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.15 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.14 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.13 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.12 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.11 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.10 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.9 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.8 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb
foobara-0.0.7 projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb