Class: OAPI::Types::Map
- Inherits:
-
Object
- Object
- Object
- OAPI::Types::Map
- Defined in:
- lib/oapi/types/map.rb
Direct Known Subclasses
OpenAPI::V30::Callbacks, OpenAPI::V30::Components::Parameters, OpenAPI::V30::Components::RequestBodies, OpenAPI::V30::Components::Schemas, OpenAPI::V30::Components::SecuritySchemes, OpenAPI::V30::Content, OpenAPI::V30::Examples, OpenAPI::V30::Headers, OpenAPI::V30::Links, OpenAPI::V30::MediaType::Encoding, OpenAPI::V30::Paths, OpenAPI::V30::Responses, OpenAPI::V30::Servers::Server::Variables
Class Attribute Summary collapse
-
.item_name ⇒ Object
readonly
Returns the value of attribute item_name.
-
.item_type ⇒ Object
readonly
Returns the value of attribute item_type.
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(store = {}) ⇒ Map
constructor
A new instance of Map.
Constructor Details
#initialize(store = {}) ⇒ Map
Returns a new instance of Map.
6 7 8 9 |
# File 'lib/oapi/types/map.rb', line 6 def initialize(store = {}, &) @store = store super(&) end |
Class Attribute Details
.item_name ⇒ Object (readonly)
Returns the value of attribute item_name.
12 13 14 |
# File 'lib/oapi/types/map.rb', line 12 def item_name @item_name end |
.item_type ⇒ Object (readonly)
Returns the value of attribute item_type.
12 13 14 |
# File 'lib/oapi/types/map.rb', line 12 def item_type @item_type end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
4 5 6 |
# File 'lib/oapi/types/map.rb', line 4 def store @store end |
Class Method Details
.item(name, type = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/oapi/types/map.rb', line 14 def item(name, type = nil) @item_name = name @item_type = type define_method(name) do |key, ref: nil, &block| raise ArgumentError, "'#{key}' already exists" if @store.include?(key.to_s) raise ArgumentError, "ref and block are mutual exclusive" if ref && block return @store[key] = OAPI::Ref.new(ref) if ref @store[key] = type.new(&block) end end |