Class: YAS::SchemaBase
- Inherits:
-
Object
- Object
- YAS::SchemaBase
- Defined in:
- lib/yas/schema.rb
Direct Known Subclasses
Class Method Summary collapse
- .exts ⇒ Object
-
.inherited(subclass) ⇒ Object
Inherited hook to inherit all extensions.
- .inspect ⇒ Object
- .use(ext) ⇒ Object
- .validate(hash) ⇒ Object
Class Method Details
.exts ⇒ Object
11 12 13 |
# File 'lib/yas/schema.rb', line 11 def self.exts @exts ||= [] end |
.inherited(subclass) ⇒ Object
Inherited hook to inherit all extensions.
30 31 32 33 34 35 |
# File 'lib/yas/schema.rb', line 30 def self.inherited subclass exts.each do |ext| subclass.use(ext) ext.when_schema_inherited(self, subclass) if ext.respond_to?(:when_schema_inherited) end end |
.inspect ⇒ Object
24 25 26 |
# File 'lib/yas/schema.rb', line 24 def self.inspect exts.inspect end |
.use(ext) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/yas/schema.rb', line 3 def self.use ext raise YAS::ExtensionError, "Duplicate Extension. Extension #{ext} is already used." if exts.include?(ext) raise YAS::ExtensionError, "Wrong Extension Format" unless ext.respond_to?(:apply) && ext.respond_to?(:when_used) exts << ext ext.when_used(self) end |
.validate(hash) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/yas/schema.rb', line 16 def self.validate hash exts.each do |ext| ext.apply(self, hash) end hash end |