Class: Macros::Ctx::ValidatePresence

Inherits:
Base
  • Object
show all
Defined in:
lib/macros/ctx/validate_presence.rb

Instance Method Summary collapse

Methods inherited from Base

register

Constructor Details

#initialize(key) ⇒ ValidatePresence

Check if the key set in the context

Examples:

key not passed

Macros::Contract::ExtractParams()

Parameters:

  • key (Symbol)


10
11
12
# File 'lib/macros/ctx/validate_presence.rb', line 10

def initialize(key)
  @key = key
end

Instance Method Details

#call(ctx) ⇒ Object

Parameters:

  • ctx (Trailblazer::Skill)

    tbl context hash



15
16
17
# File 'lib/macros/ctx/validate_presence.rb', line 15

def call(ctx, **)
  !!ctx[@key]
end