Class: OpenapiBlocks::Base

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

Overview

rubocop:disable Style/Documentation

Direct Known Subclasses

Resource

Class Attribute Summary collapse

Attributes included from Serializer

#object, #parent

Class Method Summary collapse

Methods included from Serializer

included, #initialize

Class Attribute Details

._associationsObject (readonly)

Returns the value of attribute _associations.



8
9
10
# File 'lib/openapi_blocks/base.rb', line 8

def _associations
  @_associations
end

._ignoredObject (readonly)

Returns the value of attribute _ignored.



8
9
10
# File 'lib/openapi_blocks/base.rb', line 8

def _ignored
  @_ignored
end

._modelObject (readonly)

Returns the value of attribute _model.



8
9
10
# File 'lib/openapi_blocks/base.rb', line 8

def _model
  @_model
end

._operationsObject (readonly)

Returns the value of attribute _operations.



8
9
10
# File 'lib/openapi_blocks/base.rb', line 8

def _operations
  @_operations
end

._tagsObject (readonly)

Returns the value of attribute _tags.



8
9
10
# File 'lib/openapi_blocks/base.rb', line 8

def _tags
  @_tags
end

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