Class: Highway::Steps::Parameters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/highway/steps/parameters/base.rb

Overview

This class is a base abstract class for other classes in this module. You should not use it directly.

Direct Known Subclasses

Compound, Single

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Initialize an instance.

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/highway/steps/parameters/base.rb', line 17

def initialize()
  raise NotImplementedError.new("You must not call `#{__method__.to_s}` on `#{self.class.to_s}`.")
end

Instance Attribute Details

#nameString (readonly)

Name of the parameter.

Returns:

  • (String)


24
25
26
# File 'lib/highway/steps/parameters/base.rb', line 24

def name
  @name
end

Instance Method Details

#is_required?Boolean

Whether the parameter is required.

Returns:

  • (Boolean)


29
30
31
# File 'lib/highway/steps/parameters/base.rb', line 29

def is_required?
  @required
end

#typecheck_and_validate(value, interface:, keypath: []) ⇒ Object

Typecheck and validate a value of the parameter.

This method returns typechecked, coerced and validated value or raises a fatal error if value has invalid type, can’t be coerced or is othweriwse invalid.

Parameters:

  • value (Object)

    A value.

  • interface (Highway::Interface)

    An interface instance.

  • keypath (Array<String>) (defaults to: [])

    A keypath to be used for debugging purposes.

Returns:

  • (Object)

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/highway/steps/parameters/base.rb', line 44

def typecheck_and_validate(value, interface:, keypath: [])
  raise NotImplementedError.new("You must override `#{__method__.to_s}` in `#{self.class.to_s}`.")
end