Class: Katarina::Schema
- Inherits:
-
Object
- Object
- Katarina::Schema
- Defined in:
- lib/katarina/schema.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
-
#initialize(path, controller, action, http_method, response_code, schema) ⇒ Schema
constructor
A new instance of Schema.
- #name ⇒ Object
- #types(schema = @schema) ⇒ Object
Constructor Details
#initialize(path, controller, action, http_method, response_code, schema) ⇒ Schema
Returns a new instance of Schema.
9 10 11 12 13 14 15 16 |
# File 'lib/katarina/schema.rb', line 9 def initialize(path, controller, action, http_method, response_code, schema) @path = path @controller = controller @action = action @http_method = http_method @response_code = response_code @schema = schema end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
7 8 9 |
# File 'lib/katarina/schema.rb', line 7 def controller @controller end |
Instance Method Details
#name ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/katarina/schema.rb', line 26 def name [ prefix, *Katarina::Path.include_paths(@controller.split('/')), action, response_code.to_s ].map(&:camelize).join end |
#types(schema = @schema) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/katarina/schema.rb', line 18 def types(schema = @schema) case schema in { type: 'object', properties: } then build_object(properties) in { type: 'array', items: } then [types(items)] in { type: type } then type end end |