Class: OpenapiBlocks::Base
- Inherits:
-
Object
- Object
- OpenapiBlocks::Base
- Defined in:
- lib/openapi_blocks/base.rb
Overview
rubocop:disable Style/Documentation
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.
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
Class Attribute Details
._associations ⇒ Object (readonly)
Returns the value of attribute _associations.
6 7 8 |
# File 'lib/openapi_blocks/base.rb', line 6 def _associations @_associations end |
._ignored ⇒ Object (readonly)
Returns the value of attribute _ignored.
6 7 8 |
# File 'lib/openapi_blocks/base.rb', line 6 def _ignored @_ignored end |
._model ⇒ Object (readonly)
Returns the value of attribute _model.
6 7 8 |
# File 'lib/openapi_blocks/base.rb', line 6 def _model @_model end |
._operations ⇒ Object (readonly)
Returns the value of attribute _operations.
6 7 8 |
# File 'lib/openapi_blocks/base.rb', line 6 def _operations @_operations end |
._tags ⇒ Object (readonly)
Returns the value of attribute _tags.
6 7 8 |
# File 'lib/openapi_blocks/base.rb', line 6 def @_tags end |
._virtual_attributes ⇒ Object (readonly)
Returns the value of attribute _virtual_attributes.
6 7 8 |
# File 'lib/openapi_blocks/base.rb', line 6 def _virtual_attributes @_virtual_attributes end |
Class Method Details
.association(name, type: nil, read_only: false) ⇒ Object
17 18 19 20 |
# File 'lib/openapi_blocks/base.rb', line 17 def association(name, type: nil, read_only: false) @_associations ||= [] @_associations << { name: name, type: type, read_only: read_only } end |
.attribute(name) ⇒ Object
22 23 24 25 |
# File 'lib/openapi_blocks/base.rb', line 22 def attribute(name, **) @_virtual_attributes ||= [] @_virtual_attributes << ({ name: name, ** }) end |
.ignore(*attributes) ⇒ Object
12 13 14 15 |
# File 'lib/openapi_blocks/base.rb', line 12 def ignore(*attributes) @_ignored ||= [] @_ignored.concat(attributes.map(&:to_s)) end |
.model(klass = nil) ⇒ Object
8 9 10 |
# File 'lib/openapi_blocks/base.rb', line 8 def model(klass = nil) klass ? @_model = klass : @_model ||= infer_model # rubocop:disable Naming/MemoizedInstanceVariableName end |
.operation(action, &block) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/openapi_blocks/base.rb', line 27 def operation(action, &block) @_operations ||= {} builder = OperationBuilder.new builder.instance_eval(&block) if block @_operations[action] = builder end |
.tags(*values) ⇒ Object
34 35 36 |
# File 'lib/openapi_blocks/base.rb', line 34 def (*values) values.any? ? @_tags = values : @_tags end |