class SmartCore::Schema::Checker::Reconciler

@api private @since 0.1.0 @version 0.3.0

Attributes

rules[R]

@return [SmartCore::Schema::Checker::Rules]

@api private @since 0.1.0

Public Class Methods

new() click to toggle source

@return [void]

@api private @since 0.1.0 @version 0.3.0

# File lib/smart_core/schema/checker/reconciler.rb, line 15
def initialize
  @rules = SmartCore::Schema::Checker::Rules.new
  @strict = Constructor::DEFAULT_STRICT_BEHAVIOR
  @lock = SmartCore::Engine::Lock.new
end

Public Instance Methods

__contract_rules() click to toggle source

@return [SmartCore::Schema::Checker::Rules]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/reconciler.rb, line 42
def __contract_rules
  thread_safe { rules }
end
__extra_keys_contract() click to toggle source

@return [SmartCore::Schema::Checker::Rules::ExtraKeys]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/reconciler.rb, line 34
def __extra_keys_contract
  SmartCore::Schema::Checker::Rules::ExtraKeys
end
__match!(verifiable_hash) click to toggle source

@param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash] @return [void]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/reconciler.rb, line 26
def __match!(verifiable_hash)
  thread_safe { SmartCore::Schema::Checker::Reconciler::Matcher.match(self, verifiable_hash) }
end
__strict?() click to toggle source

@return [Boolean]

@api private @since 0.3.0

# File lib/smart_core/schema/checker/reconciler.rb, line 50
def __strict?
  thread_safe { @strict }
end
non_strict!() click to toggle source

@return [void]

@api public @since 0.3.0

# File lib/smart_core/schema/checker/reconciler.rb, line 95
def non_strict!
  thread_safe { strict!(Constructor::STRICT_MODES[:non_strict]) }
end
optional(schema_key, &nested_definitions) click to toggle source

@param schema_key [String, Symbol] @param nested_definitions [Block] @return [SmartCore::Schema::Checker::Rules::Optional]

@api public @since 0.1.0 @version 0.3.0

# File lib/smart_core/schema/checker/reconciler.rb, line 75
def optional(schema_key, &nested_definitions)
  thread_safe do
    rule = SmartCore::Schema::Checker::Rules::Optional.new(self, schema_key, &nested_definitions)
    rule.tap { rules[rule.schema_key] = rule }
  end
end
required(schema_key, &nested_definitions) click to toggle source

@param schema_key [String, Symbol] @param nested_definitions [Block] @return [SmartCore::Schema::Checker::Rules::Required]

@api public @since 0.1.0 @version 0.3.0

# File lib/smart_core/schema/checker/reconciler.rb, line 61
def required(schema_key, &nested_definitions)
  thread_safe do
    rule = SmartCore::Schema::Checker::Rules::Required.new(self, schema_key, &nested_definitions)
    rule.tap { rules[rule.schema_key] = rule }
  end
end
strict!(is_strict = Constructor::DEFAULT_STRICT_BEHAVIOR) click to toggle source

@param is_strict [Boolean] @return [void]

@api public @since 0.3.0

# File lib/smart_core/schema/checker/reconciler.rb, line 87
def strict!(is_strict = Constructor::DEFAULT_STRICT_BEHAVIOR)
  thread_safe { @strict = is_strict }
end

Private Instance Methods

thread_safe(&block) click to toggle source

@param block [Block] @return [Any]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/reconciler.rb, line 112
def thread_safe(&block)
  @lock.synchronize(&block)
end