class SmartCore::Schema::Checker::Rules

@api private @since 0.1.0

@api private @since 0.1.0 rubocop:disable Style/StaticClass

Constants

TYPE_ALIASES

@todo rework with smart_type-system @note non-frized constant is used for temporary extendability @return [SmartCore::Types::Primitive]

@api private @since 0.1.0 @version 0.2.0 rubocop:disable Style/MutableConstant

Attributes

rules[R]

@return [Hash<String,SmartCore::Schema::Checker::Rules::Base>]

@api private @since 0.1.0

Public Class Methods

new() click to toggle source

@return [void]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/rules.rb, line 23
def initialize
  @rules = {}
  @lock = SmartCore::Engine::Lock.new
end

Public Instance Methods

[]=(schema_key, rule) click to toggle source

@param schema_key [String] @param rule [SmartCore::Schema::Checker::Rules::Base] @return [SmartCore::Schema::Checker::Rules::Base]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/rules.rb, line 34
def []=(schema_key, rule)
  thread_safe { rules[schema_key] = rule }
end
each(&block) click to toggle source

@param block [Block] @yield [schema_key, rule] @yieldparam schema_key [String] @yieldparam rule [SmartCore::Schema::Checker::Rules::Base] @return [Enumerable]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/rules.rb, line 46
def each(&block)
  thread_safe { block_given? ? rules.each_pair(&block) : rules.each_pair }
end
each_rule(&block) click to toggle source

@param block [Block] @yield [rule] @yieldparam rule [SmartCore::Schema::Checker::Rules::Base] @return [Enumerable]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/rules.rb, line 57
def each_rule(&block)
  thread_safe { block_given? ? rules.each_value(&block) : rules.each_value }
end
keys() click to toggle source

@return [Array<String>]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/rules.rb, line 65
def keys
  thread_safe { rules.keys }
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/rules.rb, line 82
def thread_safe(&block)
  @lock.synchronize(&block)
end