Module: EventEngine::EventDefinition::Inputs::ClassMethods

Defined in:
lib/event_engine/event_definition/inputs.rb

Instance Method Summary collapse

Instance Method Details

#input(name) ⇒ Object

Declares a required input for this event.

Parameters:

  • name (Symbol)

    the input name

Raises:

  • (ArgumentError)

    if the input is already declared



14
15
16
17
18
19
20
# File 'lib/event_engine/event_definition/inputs.rb', line 14

def input(name)
  name = name.to_sym
  if inputs.key?(name)
    raise ArgumentError, "duplicate input: #{name}"
  end
  inputs[name] = :required
end

#inputsHash{Symbol => Symbol}

Returns all declared inputs as a hash of name => :required/:optional.

Returns:

  • (Hash{Symbol => Symbol})


37
38
39
# File 'lib/event_engine/event_definition/inputs.rb', line 37

def inputs
  @inputs ||= {}
end

#optional_input(name) ⇒ Object

Declares an optional input for this event.

Parameters:

  • name (Symbol)

    the input name

Raises:

  • (ArgumentError)

    if the input is already declared



26
27
28
29
30
31
32
# File 'lib/event_engine/event_definition/inputs.rb', line 26

def optional_input(name)
  name = name.to_sym
  if inputs.key?(name)
    raise ArgumentError, "duplicate input: #{name}"
  end
  inputs[name] = :optional
end