Class: Heroics::GeneratorLink

Inherits:
Object
  • Object
show all
Defined in:
lib/heroics/client_generator.rb

Overview

A representation of a link for use when generating source code in the template.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, parameters, takes_body) ⇒ GeneratorLink

Returns a new instance of GeneratorLink.



67
68
69
70
71
72
73
74
# File 'lib/heroics/client_generator.rb', line 67

def initialize(name, description, parameters, takes_body)
  @name = Heroics.ruby_name(name)
  @description = description
  @parameters = parameters
  if takes_body
    parameters << BodyParameter.new
  end
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



65
66
67
# File 'lib/heroics/client_generator.rb', line 65

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



65
66
67
# File 'lib/heroics/client_generator.rb', line 65

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



65
66
67
# File 'lib/heroics/client_generator.rb', line 65

def parameters
  @parameters
end

#takes_bodyObject (readonly)

Returns the value of attribute takes_body.



65
66
67
# File 'lib/heroics/client_generator.rb', line 65

def takes_body
  @takes_body
end

Instance Method Details

#method_signatureObject

list of parameters for method signature, body is optional



77
78
79
# File 'lib/heroics/client_generator.rb', line 77

def method_signature
  @parameters.map { |info| info.name == 'body' ? "body = {}" : Heroics.ruby_name(info.name) }.join(', ')
end

#parameter_namesObject

list of parameters to pass along from method signature to client calls



82
83
84
# File 'lib/heroics/client_generator.rb', line 82

def parameter_names
  @parameters.map { |info| Heroics.ruby_name(info.name) }.join(', ')
end