Class: Textus::Protocol::Schema::Registry
- Inherits:
-
Object
- Object
- Textus::Protocol::Schema::Registry
- Defined in:
- lib/textus/protocol/schema/registry.rb
Instance Method Summary collapse
- #all ⇒ Object
- #by_name ⇒ Object
- #fetch(name) ⇒ Object
- #fetch_or_nil(name) ⇒ Object
-
#initialize(dir) ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize(dir) ⇒ Registry
Returns a new instance of Registry.
5 6 7 8 9 |
# File 'lib/textus/protocol/schema/registry.rb', line 5 def initialize(dir) @dir = dir @schemas = {} load_all end |
Instance Method Details
#all ⇒ Object
21 22 23 |
# File 'lib/textus/protocol/schema/registry.rb', line 21 def all @schemas.values end |
#by_name ⇒ Object
25 26 27 |
# File 'lib/textus/protocol/schema/registry.rb', line 25 def by_name @schemas.dup end |
#fetch(name) ⇒ Object
11 12 13 |
# File 'lib/textus/protocol/schema/registry.rb', line 11 def fetch(name) @schemas[name] || raise(Textus::IoError.new("schema not found: #{File.join(@dir, "#{name}.yaml")}")) end |
#fetch_or_nil(name) ⇒ Object
15 16 17 18 19 |
# File 'lib/textus/protocol/schema/registry.rb', line 15 def fetch_or_nil(name) return nil if name.nil? fetch(name) end |