Class: GoaModelGen::ModelLoader
- Inherits:
-
BaseLoader
- Object
- BaseLoader
- GoaModelGen::ModelLoader
- Defined in:
- lib/goa_model_gen/loader.rb
Instance Attribute Summary
Attributes inherited from BaseLoader
#fields_key, #kind, #path, #raw, #types_key
Instance Method Summary collapse
- #build_field(name, f) ⇒ Object
-
#initialize(path) ⇒ ModelLoader
constructor
A new instance of ModelLoader.
- #load_file ⇒ Object
Methods inherited from BaseLoader
Constructor Details
#initialize(path) ⇒ ModelLoader
Returns a new instance of ModelLoader.
37 38 39 |
# File 'lib/goa_model_gen/loader.rb', line 37 def initialize(path) super(path, Model, 'types', 'fields') end |
Instance Method Details
#build_field(name, f) ⇒ Object
48 49 50 51 52 |
# File 'lib/goa_model_gen/loader.rb', line 48 def build_field(name, f) fd = f.is_a?(Hash) ? f : {'type' => f.to_s} fd['type'] ||= 'string' super(name, fd) end |
#load_file ⇒ Object
41 42 43 44 45 46 |
# File 'lib/goa_model_gen/loader.rb', line 41 def load_file types = raw[types_key].map do |name, definition| build_type(name, definition) end SourceFile.new(path, types) end |