Module: Grape::Entity::Condition

Defined in:
lib/grape_entity/condition.rb,
lib/grape_entity/condition/base.rb,
lib/grape_entity/condition/hash_condition.rb,
lib/grape_entity/condition/block_condition.rb,
lib/grape_entity/condition/symbol_condition.rb

Defined Under Namespace

Classes: Base, BlockCondition, HashCondition, SymbolCondition

Class Method Summary collapse

Class Method Details

.new_if(arg) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/grape_entity/condition.rb', line 11

def self.new_if(arg)
  case arg
  when Hash then HashCondition.new false, arg
  when Proc then BlockCondition.new false, &arg
  when Symbol then SymbolCondition.new false, arg
  end
end

.new_unless(arg) ⇒ Object


19
20
21
22
23
24
25
# File 'lib/grape_entity/condition.rb', line 19

def self.new_unless(arg)
  case arg
  when Hash then HashCondition.new true, arg
  when Proc then BlockCondition.new true, &arg
  when Symbol then SymbolCondition.new true, arg
  end
end