Class: SmartCore::Schema::Checker::Rules Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smart_core/schema/checker/rules.rb,
lib/smart_core/schema/checker/rules/type_aliases.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.

rubocop:disable Style/StaticClass

Since:

  • 0.1.0

Defined Under Namespace

Modules: ExtraKeys, Requirement, Result, Verifier Classes: Base, Optional, Options, Required

Constant Summary collapse

TYPE_ALIASES =

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

TODO:

rework with smart_type-system

Note:

non-frized constant is used for temporary extendability

rubocop:disable Style/MutableConstant

Returns:

  • (SmartCore::Types::Primitive)

Since:

  • 0.1.0

Version:

  • 0.2.0

{
  'value.any'         => SmartCore::Types::Value::Any.nilable,
  'value.nil'         => SmartCore::Types::Value::Nil.nilable,
  'value.string'      => SmartCore::Types::Value::String.nilable,
  'value.symbol'      => SmartCore::Types::Value::Symbol.nilable,
  'value.text'        => SmartCore::Types::Value::Text.nilable,
  'value.integer'     => SmartCore::Types::Value::Integer.nilable,
  'value.float'       => SmartCore::Types::Value::Float.nilable,
  'value.numeric'     => SmartCore::Types::Value::Numeric.nilable,
  'value.big_decimal' => SmartCore::Types::Value::BigDecimal.nilable,
  'value.boolean'     => SmartCore::Types::Value::Boolean.nilable,
  'value.array'       => SmartCore::Types::Value::Array.nilable,
  'value.hash'        => SmartCore::Types::Value::Hash.nilable,
  'value.proc'        => SmartCore::Types::Value::Proc.nilable,
  'value.class'       => SmartCore::Types::Value::Class.nilable,
  'value.module'      => SmartCore::Types::Value::Module.nilable,
  'value.time'        => SmartCore::Types::Value::Time.nilable,
  'value.date_time'   => SmartCore::Types::Value::DateTime.nilable,
  'value.date'        => SmartCore::Types::Value::Date.nilable,
  'value.time_based'  => SmartCore::Types::Value::TimeBased.nilable,
  'any'               => SmartCore::Types::Value::Any.nilable,
  'nil'               => SmartCore::Types::Value::Nil.nilable,
  'string'            => SmartCore::Types::Value::String.nilable,
  'symbol'            => SmartCore::Types::Value::Symbol.nilable,
  'text'              => SmartCore::Types::Value::Text.nilable,
  'integer'           => SmartCore::Types::Value::Integer.nilable,
  'float'             => SmartCore::Types::Value::Float.nilable,
  'numeric'           => SmartCore::Types::Value::Numeric.nilable,
  'big_decimal'       => SmartCore::Types::Value::BigDecimal.nilable,
  'boolean'           => SmartCore::Types::Value::Boolean.nilable,
  'array'             => SmartCore::Types::Value::Array.nilable,
  'hash'              => SmartCore::Types::Value::Hash.nilable,
  'proc'              => SmartCore::Types::Value::Proc.nilable,
  'class'             => SmartCore::Types::Value::Class.nilable,
  'module'            => SmartCore::Types::Value::Module.nilable,
  'time'              => SmartCore::Types::Value::Time.nilable,
  'date_time'         => SmartCore::Types::Value::DateTime.nilable,
  'date'              => SmartCore::Types::Value::Date.nilable,
  'time_based'        => SmartCore::Types::Value::TimeBased.nilable
}

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.8.0



25
26
27
28
# File 'lib/smart_core/schema/checker/rules.rb', line 25

def initialize
  @rules = {}
  @cache = SmartCore::Engine::Cache.new
end

Instance Method Details

#[]=(schema_key, rule) ⇒ SmartCore::Schema::Checker::Rules::Base

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.8..0



37
38
39
40
# File 'lib/smart_core/schema/checker/rules.rb', line 37

def []=(schema_key, rule)
  cache.clear
  rules[schema_key] = rule
end

#each(&block) {|schema_key, rule| ... } ⇒ Enumerable

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:

  • block (Block)

Yields:

  • (schema_key, rule)

Yield Parameters:

Returns:

  • (Enumerable)

Since:

  • 0.1.0

Version:

  • 0.8.0



51
52
53
# File 'lib/smart_core/schema/checker/rules.rb', line 51

def each(&block)
  block_given? ? rules.each_pair(&block) : rules.each_pair
end

#each_rule(&block) {|rule| ... } ⇒ Enumerable

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:

  • block (Block)

Yields:

  • (rule)

Yield Parameters:

Returns:

  • (Enumerable)

Since:

  • 0.1.0

Version:

  • 0.8.0



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

def each_rule(&block)
  block_given? ? rules.each_value(&block) : rules.each_value
end

#keysArray<String>

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:

  • (Array<String>)

Since:

  • 0.1.0

Version:

  • 0.8.0



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

def keys
  cache.read(:keys) { rules.keys }
end