Class: OpenapiBlocks::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_blocks/base.rb

Overview

rubocop:disable Style/Documentation

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

._associationsObject (readonly)

Returns the value of attribute _associations.



6
7
8
# File 'lib/openapi_blocks/base.rb', line 6

def _associations
  @_associations
end

._ignoredObject (readonly)

Returns the value of attribute _ignored.



6
7
8
# File 'lib/openapi_blocks/base.rb', line 6

def _ignored
  @_ignored
end

._modelObject (readonly)

Returns the value of attribute _model.



6
7
8
# File 'lib/openapi_blocks/base.rb', line 6

def _model
  @_model
end

._operationsObject (readonly)

Returns the value of attribute _operations.



6
7
8
# File 'lib/openapi_blocks/base.rb', line 6

def _operations
  @_operations
end

._tagsObject (readonly)

Returns the value of attribute _tags.



6
7
8
# File 'lib/openapi_blocks/base.rb', line 6

def _tags
  @_tags
end

._virtual_attributesObject (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 tags(*values)
  values.any? ? @_tags = values : @_tags
end