Class: Orthoses::Filter
- Inherits:
-
Object
- Object
- Orthoses::Filter
- Defined in:
- lib/orthoses/filter.rb
Overview
Filter current store. filter stored key and value if proc return true
use Orthoses::Filter do |name, content|
Orthoses.rbs_defined_class?(name)
end
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(loader, if: nil, &block) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(loader, if: nil, &block) ⇒ Filter
Returns a new instance of Filter.
10 11 12 13 14 |
# File 'lib/orthoses/filter.rb', line 10 def initialize(loader, if: nil, &block) @loader = loader @if = binding.local_variable_get(:if) @block = block || @if || raise(ArgumentError, "should give a block") end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/orthoses/filter.rb', line 16 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 |