Module: CDEKApiClient::Entities::Validatable::ClassMethods

Defined in:
lib/cdek_api_client/entities/validatable.rb

Overview

Class methods for the Validatable module.

Instance Method Summary collapse

Instance Method Details

#validates(attribute, options) ⇒ Object

Defines validations for attributes.

Parameters:

  • attribute (Symbol)

    the name of the attribute to validate.

  • options (Hash)

    the validation options.

Options Hash (options):

  • :type (Symbol)

    the expected type of the attribute.

  • :presence (Boolean)

    whether the attribute is required.



21
22
23
24
# File 'lib/cdek_api_client/entities/validatable.rb', line 21

def validates(attribute, options)
  @validations ||= {}
  @validations[attribute] = options
end

#validationsHash

Returns the defined validations.

Returns:

  • (Hash)

    the defined validations.



29
30
31
# File 'lib/cdek_api_client/entities/validatable.rb', line 29

def validations
  @validations
end