class RPCoder::Function

Constants

PARAMS_IN_URL_RE

Attributes

description[RW]
method[RW]
name[RW]
path[RW]
return_type[RW]

Public Instance Methods

add_param(name, type, options = {}) click to toggle source
# File lib/rpcoder/function.rb, line 20
def add_param(name, type, options = {})
  params << Param.new(name, type, options)
end
add_return_type(name, type, options = {}) click to toggle source
# File lib/rpcoder/function.rb, line 42
def add_return_type(name, type, options = {})
  return_types << Param.new(name, type, options)
end
has_return_type?() click to toggle source
# File lib/rpcoder/function.rb, line 16
def has_return_type?
  !return_types.empty?
end
params() click to toggle source
# File lib/rpcoder/function.rb, line 8
def params
  @params ||= []
end
path_parts() click to toggle source
# File lib/rpcoder/function.rb, line 24
def path_parts
  raise "path must starts with `/`: #{path}" unless path =~ /^\//

  path_strs = path.split(PARAMS_IN_URL_RE)
  params = path.scan(PARAMS_IN_URL_RE)
  parts = []
  ([path_strs.size, params.size].max).times do |variable|
    parts << %Q{"#{path_strs.shift}"}
    parts << params.shift.sub(/^:/, '') rescue nil
  end
  parts
end
query_params() click to toggle source
# File lib/rpcoder/function.rb, line 37
def query_params
  param_strs = path.scan(PARAMS_IN_URL_RE).map { |i| i.sub(/^:/, '') }
  params.select { |i| !param_strs.include?(i.name.to_s)  }
end
return_types() click to toggle source
# File lib/rpcoder/function.rb, line 12
def return_types
  @return_types ||= []
end