Class: ActiveAgent::Delegation::Contract::DSL Private

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/active_agent/delegation/contract.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Wraps the input schema DSL so that returns inside a delegation block declares the output shape rather than an input property.

Instance Method Summary collapse

Constructor Details

#initialize(contract, schema) ⇒ DSL

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DSL.

Parameters:



101
102
103
104
# File 'lib/active_agent/delegation/contract.rb', line 101

def initialize(contract, schema)
  @contract = contract
  super(schema)
end

Instance Method Details

#returns(source = nil) { ... } ⇒ Schema

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Declares the shape the action returns.

Parameters:

  • source (Schema, Hash, Class, nil) (defaults to: nil)

Yields:

  • output DSL

Returns:



111
112
113
# File 'lib/active_agent/delegation/contract.rb', line 111

def returns(source = nil, &block)
  @contract.returns = Schema.build(source, &block)
end