Class: ActionMCP::IntegerArray

Inherits:
ActiveModel::Type::Value
  • Object
show all
Defined in:
lib/action_mcp/integer_array.rb

Overview

This temporary naming extracted from MCPangea If there is a better name, please suggest it or part of ActiveModel, open a PR

Custom type for handling arrays of integers in ActiveModel.

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Array<Integer>

Casts the given value to an array of integers.

Parameters:

  • value (Object)

    The value to cast.

Returns:

  • (Array<Integer>)

    The array of integers.



13
14
15
# File 'lib/action_mcp/integer_array.rb', line 13

def cast(value)
  Array(value).map(&:to_i) # Ensure all elements are integers
end