Sha256: 71030dfe06cc7855fe6709e44cbf96122c17bf8373bad52f3ce7cd0e6f150fcd
Contents?: true
Size: 865 Bytes
Versions: 3
Compression:
Stored size: 865 Bytes
Contents
# frozen_string_literal: true module Micro::Struct class Creator require_relative 'creator/create_module' require_relative 'creator/create_struct' def initialize(features) @features = Features.require(features) end NormalizeMemberNames = ->(values) do NormalizeNames::AsSymbols.(values, context: 'member') end def new(*members, required: nil, optional: nil, &block) optional_members = NormalizeMemberNames[optional] required_members = NormalizeMemberNames[members] + NormalizeMemberNames[required] container = CreateModule.with(required_members, optional_members, @features) struct = CreateStruct.with(required_members, optional_members, @features, &block) container.const_set(:Struct, struct) struct.const_set(:Container, container) end end private_constant :Creator end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
u-struct-0.9.0 | lib/micro/struct/creator.rb |
u-struct-0.8.0 | lib/micro/struct/creator.rb |
u-struct-0.7.0 | lib/micro/struct/creator.rb |