Class: GoaModelGen::BaseLoader
- Inherits:
-
Object
- Object
- GoaModelGen::BaseLoader
- Defined in:
- lib/goa_model_gen/loader.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fields_key ⇒ Object
readonly
Returns the value of attribute fields_key.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#types_key ⇒ Object
readonly
Returns the value of attribute types_key.
Instance Method Summary collapse
- #build_field(name, f) ⇒ Object
- #build_type(name, d) ⇒ Object
-
#initialize(path, kind, types_key, fields_key) ⇒ BaseLoader
constructor
A new instance of BaseLoader.
Constructor Details
#initialize(path, kind, types_key, fields_key) ⇒ BaseLoader
Returns a new instance of BaseLoader.
14 15 16 17 18 19 |
# File 'lib/goa_model_gen/loader.rb', line 14 def initialize(path, kind, types_key, fields_key) @path = path @kind = kind @types_key, @fields_key = types_key, fields_key @raw = YAML.load_file(path) end |
Instance Attribute Details
#fields_key ⇒ Object (readonly)
Returns the value of attribute fields_key.
13 14 15 |
# File 'lib/goa_model_gen/loader.rb', line 13 def fields_key @fields_key end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
13 14 15 |
# File 'lib/goa_model_gen/loader.rb', line 13 def kind @kind end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/goa_model_gen/loader.rb', line 12 def path @path end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
12 13 14 |
# File 'lib/goa_model_gen/loader.rb', line 12 def raw @raw end |
#types_key ⇒ Object (readonly)
Returns the value of attribute types_key.
13 14 15 |
# File 'lib/goa_model_gen/loader.rb', line 13 def types_key @types_key end |
Instance Method Details
#build_field(name, f) ⇒ Object
31 32 33 |
# File 'lib/goa_model_gen/loader.rb', line 31 def build_field(name, f) Field.new(name, f) end |
#build_type(name, d) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/goa_model_gen/loader.rb', line 21 def build_type(name, d) kind.new(name, d).tap do |t| if d[fields_key] d[fields_key].each do |fname, f| t.fields << build_field(fname, f) end end end end |