Represents an API method and its associated metadata, and provides functionality to assist in commonly performed API method tasks.
- #
- C
- E
- N
- P
- T
[R] | expects | |
[R] | name | |
[R] | public_name | |
[R] | returns |
Source: show
# 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
Backwards compatibility with previous API
Source: show
# 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
Casts a set of Ruby values into the expected Ruby values
Source: show
# File rails/actionwebservice/lib/action_web_service/api.rb, line 187 def cast_expects(params) @caster.cast_expects(params) end
Cast a Ruby return value into the expected Ruby value
Source: show
# File rails/actionwebservice/lib/action_web_service/api.rb, line 192 def cast_returns(return_value) @caster.cast_returns(return_value) end
Returns the index of the first expected parameter with the given name
Source: show
# 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
Returns a hash keyed by parameter name for the given parameter list
Source: show
# 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
The list of parameter names for this method
Source: show
# File rails/actionwebservice/lib/action_web_service/api.rb, line 181 def param_names return [] unless @expects @expects.map{ |type| type.name } end
String representation of this method
Source: show
# 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