class HaveAPI::GoClient::Action

Attributes

aliases[R]

Name aliases as returned by the API @return [Array<String>]

full_dot_name[R]

Full action name, including resource @return [String]

go_invocation_type[R]

Go type for invocation struct @return [String]

go_name[R]

Name for usage in Go @return [String]

go_request_type[R]

Go type for request struct @return [String]

go_response_type[R]

Go type for response struct @return [String]

go_type[R]

Data type for Go @return [String]

http_method[R]

@return [String]

input[R]

@return [InputOutput]

metadata[R]

@return [Metadata]

name[R]

Name as returned by the API @return [String]

output[R]

@return [InputOutput]

path[R]

@return [String]

prefix[R]
resource[R]

@return [Resource]

Public Class Methods

new(resource, name, desc, prefix: nil) click to toggle source
# File lib/haveapi/go_client/action.rb, line 57
def initialize(resource, name, desc, prefix: nil)
  @resource = resource
  @name = name.to_s
  @prefix = prefix
  @aliases = desc[:aliases]
  @full_dot_name = resource.full_dot_name + '#' + @name.capitalize
  @go_name = camelize(name)
  @go_type = full_go_type
  @go_invocation_type = go_type + 'Invocation'
  @go_request_type = go_type + 'Request'
  @go_response_type = go_type + 'Response'
  @input = desc[:input] && InputOutput.new(self, :io, :input, desc[:input])
  @output = desc[:output] && InputOutput.new(self, :io, :output, desc[:output])
  @http_method = desc[:method]
  @path = desc[:path]
  @metadata = desc[:meta] && Metadata.new(self, desc[:meta])
  @blocking = desc[:blocking]
end

Public Instance Methods

all_names() { |go_name| ... } click to toggle source

Return action name with all aliases, camelized @return [Array<String>]

# File lib/haveapi/go_client/action.rb, line 78
def all_names
  yield(go_name)
  aliases.each { |v| yield(camelize(v)) }
end
blocking?() click to toggle source
# File lib/haveapi/go_client/action.rb, line 104
def blocking?
  @blocking
end
has_input?() click to toggle source

@return [Boolean]

# File lib/haveapi/go_client/action.rb, line 89
def has_input?
  input && input.parameters.any?
end
has_output?() click to toggle source

@return [Boolean]

# File lib/haveapi/go_client/action.rb, line 94
def has_output?
  output && output.parameters.any?
end
has_path_params?() click to toggle source

@return [Boolean]

# File lib/haveapi/go_client/action.rb, line 84
def has_path_params?
  path =~ /\{[a-zA-Z\-_]+\}/
end
input_output() click to toggle source
# File lib/haveapi/go_client/action.rb, line 98
def input_output
  %i(input output).select do |v|
    send(v) && send(v).parameters.any?
  end.map { |v| send(v) }
end
resolve_associations() click to toggle source
# File lib/haveapi/go_client/action.rb, line 108
def resolve_associations
  input_output.each do |io|
    io.resolve_associations
  end

  metadata && metadata.resolve_associations
end

Protected Instance Methods

full_go_type() click to toggle source
# File lib/haveapi/go_client/action.rb, line 119
def full_go_type
  names = []
  names << camelize(prefix) if prefix
  names << 'Action'
  names.concat(resource.resource_path.map(&:go_name))
  names << go_name
  names.join('')
end