Sha256: c3b048e96c570a4ee323a7c9140d5bdfb2043177e08995a8a793118a76d539cb
Contents?: true
Size: 493 Bytes
Versions: 4
Compression:
Stored size: 493 Bytes
Contents
# frozen_string_literal: true module CheeseCloth class Filter attr_reader :klass, :conditions, :block def initialize(conditions, block) @conditions = wrap(conditions) @block = block end def run(instance) instance.instance_eval(&block) end def conditions_satisfied?(instance) conditions.all? { |condition| instance.send(condition) } end private def wrap(possible_array) [possible_array].flatten.compact end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cheesecloth-0.1.3 | lib/cheesecloth/filter.rb |
cheesecloth-0.1.2 | lib/cheesecloth/filter.rb |
cheesecloth-0.1.1 | lib/cheesecloth/filter.rb |
cheesecloth-0.1.0 | lib/cheesecloth/filter.rb |