class Cuprum::Collections::Errors::MissingDefaultContract

Error returned when validating an entity without a contract.

Constants

TYPE

Short string used to identify the type of error.

Attributes

entity_class[R]

@return [Class] the class of the assigned entity.

Public Class Methods

new(entity_class:) click to toggle source

@param entity_class [Class] The class of the assigned entity.

Calls superclass method
# File lib/cuprum/collections/errors/missing_default_contract.rb, line 14
def initialize(entity_class:)
  @entity_class = entity_class

  super(
    entity_class: entity_class,
    message:      default_message
  )
end

Public Instance Methods

as_json() click to toggle source

@return [Hash] a serializable hash representation of the error.

# File lib/cuprum/collections/errors/missing_default_contract.rb, line 27
def as_json
  {
    'data'    => {
      'entity_class' => entity_class.name
    },
    'message' => message,
    'type'    => type
  }
end
type() click to toggle source

@return [String] short string used to identify the type of error.

# File lib/cuprum/collections/errors/missing_default_contract.rb, line 38
def type
  TYPE
end

Private Instance Methods

default_message() click to toggle source
# File lib/cuprum/collections/errors/missing_default_contract.rb, line 44
def default_message
  "attempted to validate a #{entity_class.name}, but #{entity_class.name}" \
    ' does not define a default contract'
end