Class: Grape::Entity::Condition::Base
- Inherits:
-
Object
- Object
- Grape::Entity::Condition::Base
show all
- Defined in:
- lib/grape_entity/condition/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(inverse = false) ⇒ Base
Returns a new instance of Base.
11
12
13
|
# File 'lib/grape_entity/condition/base.rb', line 11
def initialize(inverse = false)
@inverse = inverse
end
|
Class Method Details
.new(inverse) ⇒ Object
7
8
9
|
# File 'lib/grape_entity/condition/base.rb', line 7
def self.new(inverse, ...)
super(inverse).tap { |e| e.setup(...) }
end
|
Instance Method Details
#==(other) ⇒ Object
15
16
17
|
# File 'lib/grape_entity/condition/base.rb', line 15
def ==(other)
(self.class == other.class) && (inversed? == other.inversed?)
end
|
#if_value(_entity, _options) ⇒ Object
27
28
29
|
# File 'lib/grape_entity/condition/base.rb', line 27
def if_value(_entity, _options)
raise NotImplementedError
end
|
#inversed? ⇒ Boolean
19
20
21
|
# File 'lib/grape_entity/condition/base.rb', line 19
def inversed?
@inverse
end
|
#met?(entity, options) ⇒ Boolean
23
24
25
|
# File 'lib/grape_entity/condition/base.rb', line 23
def met?(entity, options)
@inverse ? unless_value(entity, options) : if_value(entity, options)
end
|
#unless_value(entity, options) ⇒ Object
31
32
33
|
# File 'lib/grape_entity/condition/base.rb', line 31
def unless_value(entity, options)
!if_value(entity, options)
end
|