Class: Generator::Path
Constant Summary collapse
- HTTP_METHODS =
["delete", "get", "patch", "post", "put"].freeze
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
Instance Method Summary collapse
- #has_dynamic_sandbox? ⇒ Boolean
-
#initialize(path, methods) ⇒ Path
constructor
A new instance of Path.
- #operations ⇒ Object
- #parameters ⇒ Object
- #path ⇒ Object
- #sandbox_only? ⇒ Boolean
- #to_s ⇒ Object
Methods included from Utils
Constructor Details
#initialize(path, methods) ⇒ Path
Returns a new instance of Path.
14 15 16 17 |
# File 'lib/generator/path.rb', line 14 def initialize(path, methods) @path = path @methods = methods end |
Instance Attribute Details
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
12 13 14 |
# File 'lib/generator/path.rb', line 12 def methods @methods end |
Instance Method Details
#has_dynamic_sandbox? ⇒ Boolean
39 40 41 |
# File 'lib/generator/path.rb', line 39 def has_dynamic_sandbox? !!methods.dig("x-amzn-api-sandbox", "dynamic") end |
#operations ⇒ Object
19 20 21 22 23 |
# File 'lib/generator/path.rb', line 19 def operations methods.select { |k, _| HTTP_METHODS.include?(k) }.map do |method, operation| Operation.new(self, method, operation) end end |
#parameters ⇒ Object
35 36 37 |
# File 'lib/generator/path.rb', line 35 def parameters methods.fetch("parameters", []) end |
#path ⇒ Object
29 30 31 32 33 |
# File 'lib/generator/path.rb', line 29 def path @path.gsub(/\{([^}]+)\}/) do "\#{#{snakecase(Regexp.last_match(1))}}" end end |
#sandbox_only? ⇒ Boolean
43 44 45 |
# File 'lib/generator/path.rb', line 43 def sandbox_only? methods.key?("x-amzn-api-sandbox-only") end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/generator/path.rb', line 25 def to_s path end |