Class: R2OAS::Schema::V3::Store

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/r2-oas/schema/v3/object/store.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :obj) ⇒ Store

Returns a new instance of Store.



11
12
13
14
15
16
17
18
19
20
# File 'lib/r2-oas/schema/v3/object/store.rb', line 11

def initialize(type = :obj)
  @data = {}
  @data['type'] = type
  @data['data'] = {}
  @root_doc = {}
  @components_schema_name_list = []
  @appended_components_schema_name_list = []
  @components_request_body_name_list = []
  @appended_components_request_body_name_list = []
end

Instance Attribute Details

#appended_components_request_body_name_listObject

Returns the value of attribute appended_components_request_body_name_list.



9
10
11
# File 'lib/r2-oas/schema/v3/object/store.rb', line 9

def appended_components_request_body_name_list
  @appended_components_request_body_name_list
end

#appended_components_schema_name_listObject

Returns the value of attribute appended_components_schema_name_list.



8
9
10
# File 'lib/r2-oas/schema/v3/object/store.rb', line 8

def appended_components_schema_name_list
  @appended_components_schema_name_list
end

#components_request_body_name_listObject

Returns the value of attribute components_request_body_name_list.



9
10
11
# File 'lib/r2-oas/schema/v3/object/store.rb', line 9

def components_request_body_name_list
  @components_request_body_name_list
end

#components_schema_name_listObject

Returns the value of attribute components_schema_name_list.



8
9
10
# File 'lib/r2-oas/schema/v3/object/store.rb', line 8

def components_schema_name_list
  @components_schema_name_list
end

#root_docObject

Returns the value of attribute root_doc.



7
8
9
# File 'lib/r2-oas/schema/v3/object/store.rb', line 7

def root_doc
  @root_doc
end

Class Method Details

.create(type = :obj) ⇒ Object



40
41
42
# File 'lib/r2-oas/schema/v3/object/store.rb', line 40

def create(type = :obj)
  instance(type)
end

Instance Method Details

#add(obj_type, key, value) ⇒ Object



22
23
24
25
26
27
# File 'lib/r2-oas/schema/v3/object/store.rb', line 22

def add(obj_type, key, value)
  @data['data'][obj_type] ||= {}
  # MEMO:
  # Do not save the same thing in store by using unique contents for schema name
  @data['data'][obj_type][key] ||= value
end

#gets(obj_type) ⇒ Object



29
30
31
# File 'lib/r2-oas/schema/v3/object/store.rb', line 29

def gets(obj_type)
  (@data['data'][obj_type] || {}).values.present? ? @data['data'][obj_type].values : []
end