Sha256: 46f9102114ff0af44ad425415b89c31444f9d1fd48c4f72f753d18b89ab885fb

Contents?: true

Size: 794 Bytes

Versions: 1

Compression:

Stored size: 794 Bytes

Contents

# frozen_string_literal: true

module Micro::Struct
  module Features
    DISABLED =
      { to_ary: false,
        to_hash: false,
        to_proc: false,
        readonly: false,
        instance_copy: false
      }.freeze

    Check = ->(to_ary:, to_hash:, to_proc:, readonly:, instance_copy:) do
      { to_ary: to_ary,
        to_hash: to_hash,
        to_proc: to_proc,
        readonly: readonly,
        instance_copy: instance_copy }
    end

    NormalizeFeatureNames = ->(values) do
      NormalizeNames::AsSymbols.(values, context: 'feature')
    end

    def self.require(names)
      to_enable =
        NormalizeFeatureNames[names].each_with_object({}) { |name, memo| memo[name] = true }

      Check.(**DISABLED.merge(to_enable))
    end
  end

  private_constant :Features
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
u-struct-0.7.0 lib/micro/struct/features.rb