Represents an API method and its associated metadata, and provides functionality to assist in commonly performed API method tasks.

Methods
#
C
E
N
P
T
Attributes
[R] expects
[R] name
[R] public_name
[R] returns
Class Public methods
new(name, public_name, expects, returns)
# File rails/actionwebservice/lib/action_web_service/api.rb, line 172
def initialize(name, public_name, expects, returns)
  @name = name
  @public_name = public_name
  @expects = expects
  @returns = returns
  @caster = ActionWebService::Casting::BaseCaster.new(self)
end
Instance Public methods
[](sig_type)

Backwards compatibility with previous API

# File rails/actionwebservice/lib/action_web_service/api.rb, line 216
def [](sig_type)
  case sig_type
  when :expects
    @expects.map{|x| compat_signature_entry(x)}
  when :returns
    @returns.map{|x| compat_signature_entry(x)}
  end
end
cast_expects(params)

Casts a set of Ruby values into the expected Ruby values

# File rails/actionwebservice/lib/action_web_service/api.rb, line 187
def cast_expects(params)
  @caster.cast_expects(params)
end
cast_returns(return_value)

Cast a Ruby return value into the expected Ruby value

# File rails/actionwebservice/lib/action_web_service/api.rb, line 192
def cast_returns(return_value)
  @caster.cast_returns(return_value)
end
expects_index_of(param_name)

Returns the index of the first expected parameter with the given name

# File rails/actionwebservice/lib/action_web_service/api.rb, line 198
def expects_index_of(param_name)
  return -1 if @expects.nil?
  (0..(@expects.length-1)).each do |i|
    return i if @expects[i].name.to_s == param_name.to_s
  end
  -1
end
expects_to_hash(params)

Returns a hash keyed by parameter name for the given parameter list

# File rails/actionwebservice/lib/action_web_service/api.rb, line 208
def expects_to_hash(params)
  return {} if @expects.nil?
  h = {}
  @expects.zip(params){ |type, param| h[type.name] = param }
  h
end
param_names()

The list of parameter names for this method

# File rails/actionwebservice/lib/action_web_service/api.rb, line 181
def param_names
  return [] unless @expects
  @expects.map{ |type| type.name }
end
to_s()

String representation of this method

# File rails/actionwebservice/lib/action_web_service/api.rb, line 226
def to_s
  fqn = ""
  fqn << (@returns ? (@returns[0].human_name(false) + " ") : "void ")
  fqn << "#{@public_name}("
  fqn << @expects.map{ |p| p.human_name }.join(", ") if @expects
  fqn << ")"
  fqn
end