Class: OpenapiBlocks::Base
- Inherits:
-
Object
- Object
- OpenapiBlocks::Base
- Includes:
- Serializer
- Defined in:
- lib/openapi_blocks/base.rb
Overview
rubocop:disable Style/Documentation
Direct Known Subclasses
Class Attribute Summary collapse
-
._associations ⇒ Object
readonly
Returns the value of attribute _associations.
-
._ignored ⇒ Object
readonly
Returns the value of attribute _ignored.
-
._model ⇒ Object
readonly
Returns the value of attribute _model.
-
._operations ⇒ Object
readonly
Returns the value of attribute _operations.
-
._tags ⇒ Object
readonly
Returns the value of attribute _tags.
-
._virtual_attributes ⇒ Object
readonly
Returns the value of attribute _virtual_attributes.
Attributes included from Serializer
Class Method Summary collapse
- .association(name, type: nil, read_only: false) ⇒ Object
- .attribute(name) ⇒ Object
- .ignore(*attributes) ⇒ Object
- .model(klass = nil) ⇒ Object
- .operation(action, &block) ⇒ Object
- .tags(*values) ⇒ Object
Methods included from Serializer
Class Attribute Details
._associations ⇒ Object (readonly)
Returns the value of attribute _associations.
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def _associations @_associations end |
._ignored ⇒ Object (readonly)
Returns the value of attribute _ignored.
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def _ignored @_ignored end |
._model ⇒ Object (readonly)
Returns the value of attribute _model.
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def _model @_model end |
._operations ⇒ Object (readonly)
Returns the value of attribute _operations.
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def _operations @_operations end |
._tags ⇒ Object (readonly)
Returns the value of attribute _tags.
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def @_tags end |
._virtual_attributes ⇒ Object (readonly)
Returns the value of attribute _virtual_attributes.
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def _virtual_attributes @_virtual_attributes end |
Class Method Details
.association(name, type: nil, read_only: false) ⇒ Object
19 20 21 22 |
# File 'lib/openapi_blocks/base.rb', line 19 def association(name, type: nil, read_only: false) @_associations ||= [] @_associations << { name: name, type: type, read_only: read_only } end |
.attribute(name) ⇒ Object
24 25 26 27 |
# File 'lib/openapi_blocks/base.rb', line 24 def attribute(name, **) @_virtual_attributes ||= [] @_virtual_attributes << ({ name: name, ** }) end |
.ignore(*attributes) ⇒ Object
14 15 16 17 |
# File 'lib/openapi_blocks/base.rb', line 14 def ignore(*attributes) @_ignored ||= [] @_ignored.concat(attributes.map(&:to_s)) end |
.model(klass = nil) ⇒ Object
10 11 12 |
# File 'lib/openapi_blocks/base.rb', line 10 def model(klass = nil) klass ? @_model = klass : @_model ||= infer_model # rubocop:disable Naming/MemoizedInstanceVariableName end |
.operation(action, &block) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/openapi_blocks/base.rb', line 29 def operation(action, &block) @_operations ||= {} builder = OperationBuilder.new builder.instance_eval(&block) if block @_operations[action] = builder end |
.tags(*values) ⇒ Object
36 37 38 |
# File 'lib/openapi_blocks/base.rb', line 36 def (*values) values.any? ? @_tags = values : @_tags end |