Module: DWH::Functions::Nulls

Included in:
DWH::Functions
Defined in:
lib/dwh/functions/nulls.rb

Overview

Manages translations to Null handling Functions

Instance Method Summary collapse

Instance Method Details

#if_null(exp, exp_if_null) ⇒ Object

If the provided expression is null then return the second expression.

Parameters:

  • exp (String)
    • target expression
  • exp_if_null (String)
    • exp if target is null


9
10
11
12
13
# File 'lib/dwh/functions/nulls.rb', line 9

def if_null(exp, exp_if_null)
  gsk(:if_null)
    .sub(/@exp/i, exp.to_s)
    .sub(/@when_null/i, exp_if_null.to_s)
end

#null_if(exp, target_exp) ⇒ Object

Returns Null if the given expression equals the target expression.



17
18
19
20
21
# File 'lib/dwh/functions/nulls.rb', line 17

def null_if(exp, target_exp)
  gsk(:null_if)
    .sub(/@exp/i, exp.to_s)
    .sub(/@target/i, target_exp.to_s)
end

#null_if_zero(exp) ⇒ Object

Returns Null if the given expression evaluates to zero.



25
26
27
28
# File 'lib/dwh/functions/nulls.rb', line 25

def null_if_zero(exp)
  gsk(:null_if_zero)
    .sub(/@exp/i, exp.to_s)
end