Sha256: dbbb92fad06524bf229a9a6e4b985235d8da3d2cf34b305f1de9ca54f1c81155

Contents?: true

Size: 849 Bytes

Versions: 3

Compression:

Stored size: 849 Bytes

Contents

require "English"

module Foobara
  module Generators
    module TypeGenerator
      class TypeConfig < Foobara::Model
        class TypeType
          TYPE = :type
          MODEL = :model
          ENTITY = :entity
        end

        attributes do
          name :string
          type :string, default: TypeType::TYPE, one_of: TypeType
          description :string, :allow_nil
          domain :string, :allow_nil
          organization :string, :allow_nil
        end

        def module_path
          @module_path ||= domain_path + post_domain_path
        end

        def domain_path
          @domain_path ||= [*organization&.split("::"), *domain&.split("::")]
        end

        def post_domain_path
          name.split("::")
        end

        def has_domain?
          !domain_path.empty?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foobara-type-generator-0.0.4 src/type_config.rb
foobara-type-generator-0.0.3 src/type_config.rb
foobara-type-generator-0.0.2 src/type_config.rb