Sha256: bf4cc59b8bc942f597991a0aaae127c4612f9362747d4a2c99f2670347b04985
Contents?: true
Size: 766 Bytes
Versions: 3
Compression:
Stored size: 766 Bytes
Contents
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) && (self.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) fail NotImplementedError end def unless_value(entity, options) !if_value(entity, options) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-entity-0.5.2 | lib/grape_entity/condition/base.rb |
grape-entity-0.5.1 | lib/grape_entity/condition/base.rb |
grape-entity-0.5.0 | lib/grape_entity/condition/base.rb |