pocke / rbs_rails

Apache License 2.0
285 stars 33 forks source link

How to skip a method from gems? #230

Closed khrisnagunanasurya closed 2 years ago

khrisnagunanasurya commented 2 years ago

Hi, I have a problem with how to mock/ignore the classes or methods from gems, I use a gem called AASM, where when we include the AASM into the model, we can use the helper method like aasm, transitions, ... etc. But I'm unable to make RBS ignore those methods or try to mock them inside RBS. can someone help me with this?

What I've been trying so far

  class History < ::ApplicationRecord
    ...

    module AasmGem
      module ClassMethods
        def aasm: (*untyped) { () -> void } -> void

        def event: (Symbol) -> void

        def transitions: (from: Symbol, to: Symbol) -> void
      end
    end
    include AasmGem

    ...
  end
ksss commented 2 years ago

How about to use extend instead of include?

- include AasmGem
+ extend AasmGem::ClassMethods
khrisnagunanasurya commented 2 years ago

Thanks, it's working