Module: Serega::SeregaValidations::CheckAttributeParams::InstanceMethods

Included in:
Serega::SeregaValidations::CheckAttributeParams
Defined in:
lib/serega/validations/check_attribute_params.rb

Overview

Validations for attribute params instance methods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blocknil, Proc (readonly)

Returns validated attribute block.

Returns:

  • (nil, Proc)

    validated attribute block



23
24
25
# File 'lib/serega/validations/check_attribute_params.rb', line 23

def block
  @block
end

#nameSymbol (readonly)

Returns validated attribute name.

Returns:

  • (Symbol)

    validated attribute name



17
18
19
# File 'lib/serega/validations/check_attribute_params.rb', line 17

def name
  @name
end

#optsHash (readonly)

Returns validated attribute options.

Returns:

  • (Hash)

    validated attribute options



20
21
22
# File 'lib/serega/validations/check_attribute_params.rb', line 20

def opts
  @opts
end

Instance Method Details

#initialize(name, opts, block) ⇒ void

Initializes attribute params validator

Parameters:

  • name (Symbol)

    attribute name

  • opts (Hash)

    attribute options

  • block (nil, Proc)

    block provided to attribute



34
35
36
37
38
# File 'lib/serega/validations/check_attribute_params.rb', line 34

def initialize(name, opts, block)
  @name = name
  @opts = opts
  @block = block
end

#validateObject

Validates attribute params



43
44
45
46
47
# File 'lib/serega/validations/check_attribute_params.rb', line 43

def validate
  check_name
  check_opts
  check_block
end