Sha256: 150b9a98d92e728e96508e7727b0bc2aca22333b53143cdb5250bb648842eb09
Contents?: true
Size: 793 Bytes
Versions: 4
Compression:
Stored size: 793 Bytes
Contents
# frozen_string_literal: true module Grape class Entity module Condition class Base def self.new(inverse, *args, &block) super(inverse).tap { |e| e.setup(*args, &block) } end def initialize(inverse = false) @inverse = inverse end def ==(other) (self.class == other.class) && (inversed? == other.inversed?) end def inversed? @inverse end def met?(entity, options) !@inverse ? if_value(entity, options) : unless_value(entity, options) end def if_value(_entity, _options) raise NotImplementedError end def unless_value(entity, options) !if_value(entity, options) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems