Class: JsonSchemaView::Configuration::SchemaSetDictionary
- Inherits:
-
Delegator
- Object
- Delegator
- JsonSchemaView::Configuration::SchemaSetDictionary
- Defined in:
- lib/json_schema_view/configuration/schema_set_dictionary.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- # ⇒ HashWithIndifferentAccess{Symbol => Symbol}
- # ⇒ Object
- #fetch_instance(key) ⇒ SchemaSet
-
#initialize(contents = nil) ⇒ SchemaSetDictionary
constructor
A new instance of SchemaSetDictionary.
Constructor Details
#initialize(contents = nil) ⇒ SchemaSetDictionary
Returns a new instance of SchemaSetDictionary.
12 13 14 15 |
# File 'lib/json_schema_view/configuration/schema_set_dictionary.rb', line 12 def initialize(contents = nil) @hash = ActiveSupport::HashWithIndifferentAccess.new(contents) super end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
9 10 11 |
# File 'lib/json_schema_view/configuration/schema_set_dictionary.rb', line 9 def hash @hash end |
Instance Method Details
#[]=(key, value) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/json_schema_view/configuration/schema_set_dictionary.rb', line 30 def []=(key, value) raise TypeError, "key (#{key}) cannot be converted to a symbol" unless key.respond_to?(:to_sym) if !value.is_a?(String) && !value.is_a?(Symbol) raise TypeError, "value (#{value}) must be the name of SchemaSet class" end hash[key.to_sym] = value.to_sym end |
# ⇒ HashWithIndifferentAccess{Symbol => Symbol}
19 20 21 |
# File 'lib/json_schema_view/configuration/schema_set_dictionary.rb', line 19 def __getobj__ hash end |
# ⇒ Object
24 25 26 |
# File 'lib/json_schema_view/configuration/schema_set_dictionary.rb', line 24 def __setobj__(_) # noop end |
#fetch_instance(key) ⇒ SchemaSet
42 43 44 45 46 47 48 |
# File 'lib/json_schema_view/configuration/schema_set_dictionary.rb', line 42 def fetch_instance(key) klass = fetch(key).constantize raise TypeError, "#{klass} is not the name of SchemaSet class" unless klass < JsonSchemaView::SchemaSet klass.new end |