Class: SmartCore::Types::Primitive::InvariantControl::Single Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/types/primitive/invariant_control/single.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.2.0

Version:

  • 0.8.0

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, invariant_checker) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (String)
  • invariant_checker (Proc)

Since:

  • 0.2.0



33
34
35
36
# File 'lib/smart_core/types/primitive/invariant_control/single.rb', line 33

def initialize(name, invariant_checker)
  @name = name.dup.tap(&:freeze)
  @invariant_checker = invariant_checker
end

Instance Attribute Details

#nameString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)

Since:

  • 0.2.0



25
26
27
# File 'lib/smart_core/types/primitive/invariant_control/single.rb', line 25

def name
  @name
end

Class Method Details

.create(name, invariant_checker) ⇒ SmartCore::Types::Primitive::InvariantControl::Single

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • name (String, Symbol)
  • invariant_checker (Proc)

Returns:

Since:

  • 0.2.0



16
17
18
# File 'lib/smart_core/types/primitive/invariant_control/single.rb', line 16

def create(name, invariant_checker)
  new(name.to_s, invariant_checker)
end

Instance Method Details

#check(value, runtime_attributes) ⇒ SmartCore::Types::Primitive::InvariantControl::Single::Result

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Any)
  • runtime_attributes (Array<Any>)

Returns:

Since:

  • 0.2.0

Version:

  • 0.3.0



45
46
47
48
# File 'lib/smart_core/types/primitive/invariant_control/single.rb', line 45

def check(value, runtime_attributes)
  validation_result = !!invariant_checker.call(value, runtime_attributes)
  Result.new(self, value, validation_result)
end

#simply_check(value, runtime_attributes) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Any)
  • runtime_attributes (Array<Any>)

Returns:

  • (Boolean)

Since:

  • 0.8.0



56
57
58
# File 'lib/smart_core/types/primitive/invariant_control/single.rb', line 56

def simply_check(value, runtime_attributes)
  !!invariant_checker.call(value, runtime_attributes)
end