Sha256: ca00c9eeae1823563aafb4c37d730b0911e89256a0f0712ae64f7c87b7e333c6

Contents?: true

Size: 1002 Bytes

Versions: 7

Compression:

Stored size: 1002 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.2.0
class SmartCore::Types::Primitive::InvariantControl::Factory::ChainDefinitionContext
  # @return [SmartCore::Types::Primitive::InvariantControl::Chain]
  #
  # @api private
  # @since 0.2.0
  attr_reader :___chain___

  # @param chain_name [String]
  # @return [void]
  #
  # @api privae
  # @since 0.2.0
  def initialize(chain_name)
    @___chain___ = SmartCore::Types::Primitive::InvariantControl::Chain.new(chain_name)
  end

  # @param invariant_name [String, Symbol]
  # @param invariant_definition [Block]
  # @return [void]
  #
  # @api private
  # @since 0.2.0
  def invariant(invariant_name, &invariant_definition)
    SmartCore::Types::Primitive::Factory::DefinitionContext.vaildate_invariant_attributes!(
      invariant_name,
      &invariant_definition
    )

    ___chain___.add_invariant(
      SmartCore::Types::Primitive::InvariantControl::Single.create(
        invariant_name, invariant_definition
      )
    )
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smart_types-0.8.0 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
smart_types-0.7.1 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
smart_types-0.7.0 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
smart_types-0.6.0 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
smart_types-0.4.0 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
smart_types-0.3.0 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb
smart_types-0.2.0 lib/smart_core/types/primitive/invariant_control/factory/chain_definition_context.rb