Class: ActiveAgent::Parameterized::Agent Private

Inherits:
Object
  • Object
show all
Defined in:
lib/active_agent/concerns/parameterized.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.

Proxy class that intercepts method calls to create parameterized generations.

This class is returned by ClassMethods#with and acts as a proxy to the actual agent class, capturing method calls to actions and creating Generation instances with the stored parameters.

Instance Method Summary collapse

Constructor Details

#initialize(agent, params) ⇒ Agent

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 Agent.

Parameters:

  • agent (Class)

    the agent class to proxy

  • params (Hash)

    the parameters to pass to agent instances



113
114
115
116
# File 'lib/active_agent/concerns/parameterized.rb', line 113

def initialize(agent, params)
  @agent = agent
  @params = params
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name) ⇒ ActiveAgent::Parameterized::Generation

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.

Intercepts calls to agent action methods and creates parameterized generations.

Parameters:

  • method_name (Symbol)

    the name of the action method being called

  • args (Array)

    arguments to pass to the action method

Returns:

Raises:

  • (NoMethodError)

    if the method doesn’t exist on the agent class



125
126
127
128
129
130
131
# File 'lib/active_agent/concerns/parameterized.rb', line 125

def method_missing(method_name, ...)
  if @agent.public_instance_methods.include?(method_name)
    ActiveAgent::Parameterized::Generation.new(@agent, method_name, @params, ...)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(method, include_all = false) ⇒ Boolean

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 true if the agent responds to the method.

Parameters:

  • method (Symbol)

    the method name to check

  • include_all (Boolean) (defaults to: false)

    whether to include private and protected methods

Returns:

  • (Boolean)

    true if the agent responds to the method



136
137
138
# File 'lib/active_agent/concerns/parameterized.rb', line 136

def respond_to_missing?(method, include_all = false)
  @agent.respond_to?(method, include_all)
end