Class: Swarker::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/swarker/path.rb

Constant Summary collapse

DEFAULT_SCHEMA =
{
  produces: ['application/json'.freeze]
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, original_schema, preparsed = false) ⇒ Path

Returns a new instance of Path.



9
10
11
12
13
14
15
# File 'lib/swarker/path.rb', line 9

def initialize(name, original_schema, preparsed = false)
  @name            = name
  @original_schema = HashWithIndifferentAccess.new(original_schema)
  @preparsed       = preparsed

  parse_schema
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/swarker/path.rb', line 3

def name
  @name
end

#schemaObject (readonly)

Returns the value of attribute schema.



3
4
5
# File 'lib/swarker/path.rb', line 3

def schema
  @schema
end

Instance Method Details

#verbObject



17
18
19
20
# File 'lib/swarker/path.rb', line 17

def verb
  # Lurker schema has only one request verb per file
  @verb ||= @preparsed ? @schema.keys.first : original_schema[:extensions][:method].downcase
end