Class: SmartCore::Schema::Checker Private

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/schema/checker.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.1.0

Version:

  • 0.9.0

Defined Under Namespace

Classes: Reconciler, Rules, VerifiableHash

Instance Method Summary collapse

Constructor Details

#initializevoid

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.

Since:

  • 0.1.0

Version:

  • 0.9.0



16
17
18
19
# File 'lib/smart_core/schema/checker.rb', line 16

def initialize
  @reconciler = Reconciler::Constructor.create
  @lock = SmartCore::Engine::ReadWriteLock.new
end

Instance Method Details

#append_schema_definitions(&definitions) ⇒ 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.

This method returns an undefined value.

Parameters:

  • definitions (Block)

Since:

  • 0.1.0

Version:

  • 0.9.0



63
64
65
# File 'lib/smart_core/schema/checker.rb', line 63

def append_schema_definitions(&definitions)
  @lock.write_sync { add_schema_definitions(&definitions) }
end

#check!(verifiable_hash) ⇒ SmartCore::Schema::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:

  • verifiable_hash (Hash<String|Symbol,Any>)

Returns:

Since:

  • 0.1.0

Version:

  • 0.9.0



27
28
29
30
31
32
33
34
35
# File 'lib/smart_core/schema/checker.rb', line 27

def check!(verifiable_hash)
  @lock.read_sync do
    raise(SmartCore::Schema::ArgumentError, <<~ERROR_MESSAGE) unless verifiable_hash.is_a?(Hash)
      Verifiable hash should be a type of ::Hash
    ERROR_MESSAGE

    reconciler.__match!(VerifiableHash.new(verifiable_hash)).complete!
  end
end

#combine_with(another_checker) ⇒ SmartCore::Schema::Checker

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:

Returns:

Since:

  • 0.1.0

Version:

  • 0.9.0



73
74
75
# File 'lib/smart_core/schema/checker.rb', line 73

def combine_with(another_checker)
  @lock.write_sync { self } # TODO (0.x.0): merge the definitions and return self
end

#invoke_in_pipe(&checker_invokations) ⇒ 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.

This method returns an undefined value.

Parameters:

  • checker_invokations (Block)

Since:

  • 0.3.0

Version:

  • 0.9.0



43
44
45
# File 'lib/smart_core/schema/checker.rb', line 43

def invoke_in_pipe(&checker_invokations)
  @lock.write_sync { instance_eval(&checker_invokations) }
end

#set_strict_mode(strict_mode) ⇒ 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.

This method returns an undefined value.

Parameters:

  • strict_mode (NilClass, String, Symbol)

Since:

  • 0.3.0

Version:

  • 0.9.0



53
54
55
# File 'lib/smart_core/schema/checker.rb', line 53

def set_strict_mode(strict_mode)
  @lock.write_sync { apply_strict_mode(strict_mode) }
end