Sha256: 06c025f7571b0b49ba8b89c7ceba3f4606b44451a234b2d18cbc5aec54dbf047

Contents?: true

Size: 710 Bytes

Versions: 11

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

module Orthoses
  # Filter current store.
  # filter stored key and value if proc return true
  #   use Orthoses::Filter do |name, content|
  #     Orthoses.rbs_defined_class?(name)
  #   end
  class Filter
    def initialize(loader, if: nil, &block)
      @loader = loader
      @if = binding.local_variable_get(:if)
      @block = block || @if || raise(ArgumentError, "should give a block")
    end

    def call
      @loader.call.tap do |store|
        store.filter! do |name, content|
          @block.call(name, content).tap do |bool|
            Orthoses.logger.debug("[Filter] #{bool ? "Pass" : "Reject"} [#{name}]")
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
orthoses-1.17.0 lib/orthoses/filter.rb
orthoses-1.16.0 lib/orthoses/filter.rb
orthoses-1.15.0 lib/orthoses/filter.rb
orthoses-1.14.0 lib/orthoses/filter.rb
orthoses-1.13.0 lib/orthoses/filter.rb
orthoses-1.12.0 lib/orthoses/filter.rb
orthoses-1.11.0 lib/orthoses/filter.rb
orthoses-1.10.0 lib/orthoses/filter.rb
orthoses-1.9.0 lib/orthoses/filter.rb
orthoses-1.8.0 lib/orthoses/filter.rb
orthoses-1.7.0 lib/orthoses/filter.rb