module Grape::Entity::Condition

Public Class Methods

new_if(arg) click to toggle source
# File lib/grape_entity/condition.rb, line 11
def new_if(arg)
  condition(false, arg)
end
new_unless(arg) click to toggle source
# File lib/grape_entity/condition.rb, line 15
def new_unless(arg)
  condition(true, arg)
end

Private Class Methods

condition(inverse, arg) click to toggle source
# File lib/grape_entity/condition.rb, line 21
def condition(inverse, arg)
  condition_klass =
    case arg
    when Hash then HashCondition
    when Proc then BlockCondition
    when Symbol then SymbolCondition
    end

  condition_klass.new(inverse, arg)
end