Sha256: 478832964db3bdef0e678eea69a011feac8d6053f142b7912dcde336b3aad591
Contents?: true
Size: 968 Bytes
Versions: 30
Compression:
Stored size: 968 Bytes
Contents
module Refine::Blueprints class Blueprint # DSL-based model for building filter blueprints attr_reader :blueprint def initialize @blueprint = [] @depth = 0 end def group(&block) @depth = @depth += 1 instance_eval(&block) @depth = @depth -= 1 self end def criterion(condition_id, input) if !@blueprint.blank? && @blueprint.last[:type] == "criterion" raise "Conjunction missing" end add({ depth: @depth, type: "criterion", condition_id: condition_id, input: input, }) self end def conjunction(word) add({ depth: @depth, type: "conjunction", word: word }) end def and conjunction("and") self end def or conjunction("or") self end def add(item) @blueprint.append(item) end def to_array @blueprint end end end
Version data entries
30 entries across 30 versions & 1 rubygems