Sha256: d6a133b72961a3b57edc4c848a2a0b1141ed9ba0ede30afe23e77b85abaacb57

Contents?: true

Size: 593 Bytes

Versions: 11

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

module Orthoses
  # Filter current store.
  #   use Orthoses::Filter,
  #     # filter stored key and value if proc return true
  #     if: -> (name, content) { Orthoses.rbs_defined_class?(name) }
  class Filter
    def initialize(loader, if:)
      @loader = loader
      @if = binding.local_variable_get(:if)
    end

    def call
      @loader.call.tap do |store|
        store.filter! do |name, content|
          @if.call(name, content).tap do
            Orthoses.logger.debug("Filter pass [#{name}]")
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
orthoses-0.11.0 lib/orthoses/filter.rb
orthoses-0.10.0 lib/orthoses/filter.rb
orthoses-0.9.0 lib/orthoses/filter.rb
orthoses-0.8.0 lib/orthoses/filter.rb
orthoses-0.7.0 lib/orthoses/filter.rb
orthoses-0.6.0 lib/orthoses/filter.rb
orthoses-0.5.0 lib/orthoses/filter.rb
orthoses-0.4.0 lib/orthoses/filter.rb
orthoses-0.3.0 lib/orthoses/filter.rb
orthoses-0.2.0 lib/orthoses/filter.rb
orthoses-0.1.0 lib/orthoses/filter.rb