Class: Prmd::SchemaHash
- Inherits:
-
Object
- Object
- Prmd::SchemaHash
- Extended by:
- Forwardable
- Defined in:
- lib/prmd/core/schema_hash.rb
Overview
Specialized Hash for handling loaded Schema data
Instance Attribute Summary collapse
- #filename ⇒ String readonly
Instance Method Summary collapse
- #fetch(key) ⇒ self
-
#initialize(data, options = {}) ⇒ SchemaHash
constructor
A new instance of SchemaHash.
- #initialize_copy(other) ⇒ self
- #to_h ⇒ Hash
Constructor Details
#initialize(data, options = {}) ⇒ SchemaHash
Returns a new instance of SchemaHash.
21 22 23 24 |
# File 'lib/prmd/core/schema_hash.rb', line 21 def initialize(data, = {}) @data = data @filename = .fetch(:filename, '') end |
Instance Attribute Details
#filename ⇒ String (readonly)
12 13 14 |
# File 'lib/prmd/core/schema_hash.rb', line 12 def filename @filename end |
Instance Method Details
#fetch(key) ⇒ self
36 37 38 |
# File 'lib/prmd/core/schema_hash.rb', line 36 def fetch(key) @data.fetch(key) { abort "Missing key #{key} in #{filename}" } end |
#initialize_copy(other) ⇒ self
28 29 30 31 32 |
# File 'lib/prmd/core/schema_hash.rb', line 28 def initialize_copy(other) super @data = other.data.dup @filename = other.filename.dup end |
#to_h ⇒ Hash
41 42 43 |
# File 'lib/prmd/core/schema_hash.rb', line 41 def to_h @data.dup end |