Sha256: ef97020a6c4f01c34dc665e6a6371b11269f1ae6bf5e610394682f02ec9bb5a6

Contents?: true

Size: 792 Bytes

Versions: 30

Compression:

Stored size: 792 Bytes

Contents

# typed: strict
# frozen_string_literal: true

module Tapioca
  module Gem
    module Listeners
      class SorbetEnums < Base
        extend T::Sig

        private

        sig { override.params(event: ScopeNodeAdded).void }
        def on_scope(event)
          constant = event.constant
          return unless T::Enum > event.constant # rubocop:disable Style/InvertibleUnlessCondition

          enums = T.unsafe(constant).values.map do |enum_type|
            enum_type.instance_variable_get(:@const_name).to_s
          end

          event.node << RBI::TEnumBlock.new(enums)
        end

        sig { override.params(event: NodeAdded).returns(T::Boolean) }
        def ignore?(event)
          event.is_a?(Tapioca::Gem::ForeignScopeNodeAdded)
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
tapioca-0.16.1 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.16.0 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.15.1 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.15.0 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.14.4 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.14.3 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.13.3 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.13.2 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.13.1 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.13.0 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.12.0 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.17 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.16 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.15 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.14 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.13 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.12 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.11 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.10 lib/tapioca/gem/listeners/sorbet_enums.rb
tapioca-0.11.9 lib/tapioca/gem/listeners/sorbet_enums.rb