Class: HaveAPI::GoClient::Action
- Inherits:
-
Object
- Object
- HaveAPI::GoClient::Action
- Includes:
- Utils
- Defined in:
- lib/haveapi/go_client/action.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Array<String>
readonly
Name aliases as returned by the API.
-
#full_dot_name ⇒ String
readonly
Full action name, including resource.
-
#go_invocation_type ⇒ String
readonly
Go type for invocation struct.
-
#go_name ⇒ String
readonly
Name for usage in Go.
-
#go_request_type ⇒ String
readonly
Go type for request struct.
-
#go_response_type ⇒ String
readonly
Go type for response struct.
-
#go_type ⇒ String
readonly
Data type for Go.
- #http_method ⇒ String readonly
- #input ⇒ InputOutput readonly
- #metadata ⇒ Metadata readonly
-
#name ⇒ String
readonly
Name as returned by the API.
- #output ⇒ InputOutput readonly
- #path ⇒ String readonly
- #resource ⇒ Resource readonly
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#all_names {|go_name| ... } ⇒ Array<String>
Return action name with all aliases, camelized.
- #blocking? ⇒ Boolean
- #has_input? ⇒ Boolean
- #has_output? ⇒ Boolean
- #has_path_params? ⇒ Boolean
-
#initialize(resource, name, desc, prefix: nil) ⇒ Action
constructor
A new instance of Action.
- #input_output ⇒ Object
- #resolve_associations ⇒ Object
Methods included from Utils
Constructor Details
#initialize(resource, name, desc, prefix: nil) ⇒ Action
Returns a new instance of Action.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 |
Instance Attribute Details
#aliases ⇒ Array<String> (readonly)
Name aliases as returned by the API
16 17 18 |
# File 'lib/haveapi/go_client/action.rb', line 16 def aliases @aliases end |
#full_dot_name ⇒ String (readonly)
Full action name, including resource
20 21 22 |
# File 'lib/haveapi/go_client/action.rb', line 20 def full_dot_name @full_dot_name end |
#go_invocation_type ⇒ String (readonly)
Go type for invocation struct
47 48 49 |
# File 'lib/haveapi/go_client/action.rb', line 47 def go_invocation_type @go_invocation_type end |
#go_name ⇒ String (readonly)
Name for usage in Go
24 25 26 |
# File 'lib/haveapi/go_client/action.rb', line 24 def go_name @go_name end |
#go_request_type ⇒ String (readonly)
Go type for request struct
51 52 53 |
# File 'lib/haveapi/go_client/action.rb', line 51 def go_request_type @go_request_type end |
#go_response_type ⇒ String (readonly)
Go type for response struct
55 56 57 |
# File 'lib/haveapi/go_client/action.rb', line 55 def go_response_type @go_response_type end |
#go_type ⇒ String (readonly)
Data type for Go
28 29 30 |
# File 'lib/haveapi/go_client/action.rb', line 28 def go_type @go_type end |
#http_method ⇒ String (readonly)
40 41 42 |
# File 'lib/haveapi/go_client/action.rb', line 40 def http_method @http_method end |
#input ⇒ InputOutput (readonly)
34 35 36 |
# File 'lib/haveapi/go_client/action.rb', line 34 def input @input end |
#metadata ⇒ Metadata (readonly)
31 32 33 |
# File 'lib/haveapi/go_client/action.rb', line 31 def @metadata end |
#name ⇒ String (readonly)
Name as returned by the API
12 13 14 |
# File 'lib/haveapi/go_client/action.rb', line 12 def name @name end |
#output ⇒ InputOutput (readonly)
37 38 39 |
# File 'lib/haveapi/go_client/action.rb', line 37 def output @output end |
#path ⇒ String (readonly)
43 44 45 |
# File 'lib/haveapi/go_client/action.rb', line 43 def path @path end |
#resource ⇒ Resource (readonly)
8 9 10 |
# File 'lib/haveapi/go_client/action.rb', line 8 def resource @resource end |
Instance Method Details
#<=>(other) ⇒ Object
114 115 116 |
# File 'lib/haveapi/go_client/action.rb', line 114 def <=>(other) go_name <=> other.go_name end |
#all_names {|go_name| ... } ⇒ Array<String>
Return action name with all aliases, camelized
78 79 80 81 |
# File 'lib/haveapi/go_client/action.rb', line 78 def all_names yield(go_name) aliases.each { |v| yield(camelize(v)) } end |
#blocking? ⇒ Boolean
104 105 106 |
# File 'lib/haveapi/go_client/action.rb', line 104 def blocking? @blocking end |
#has_input? ⇒ Boolean
89 90 91 |
# File 'lib/haveapi/go_client/action.rb', line 89 def has_input? input && input.parameters.any? end |
#has_output? ⇒ Boolean
94 95 96 |
# File 'lib/haveapi/go_client/action.rb', line 94 def has_output? output && output.parameters.any? end |
#has_path_params? ⇒ Boolean
84 85 86 |
# File 'lib/haveapi/go_client/action.rb', line 84 def has_path_params? path =~ /\{[a-zA-Z0-9\-_]+\}/ end |
#input_output ⇒ Object
98 99 100 101 102 |
# 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 ⇒ Object
108 109 110 111 112 |
# File 'lib/haveapi/go_client/action.rb', line 108 def resolve_associations input_output.each(&:resolve_associations) && .resolve_associations end |