Class: AmsLayout::DelegateWriter
- Inherits:
-
Object
- Object
- AmsLayout::DelegateWriter
- Defined in:
- lib/ams_layout/delegate_writer.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Name of this class.
-
#delegated_class_name ⇒ Object
Name of class we will delegate to.
-
#source_file_name ⇒ Object
Name of this class’ source file.
Instance Method Summary collapse
-
#aliases ⇒ Object
List of aliases for specified fields.
- #aliases=(data) ⇒ Object
-
#write(stream, layout) ⇒ Object
Write a class file, based on the the layout.yml, to the provided stream.
Instance Attribute Details
#class_name ⇒ Object
Name of this class
33 34 35 |
# File 'lib/ams_layout/delegate_writer.rb', line 33 def class_name @class_name ||= AmsLayout.configuration.delegate_class_name end |
#delegated_class_name ⇒ Object
Name of class we will delegate to
41 42 43 |
# File 'lib/ams_layout/delegate_writer.rb', line 41 def delegated_class_name @delegated_class_name ||= AmsLayout.configuration.layout_class_name end |
#source_file_name ⇒ Object
Name of this class’ source file
25 26 27 |
# File 'lib/ams_layout/delegate_writer.rb', line 25 def source_file_name class_name.ams_layout_snakecase + '.rb' end |
Instance Method Details
#aliases ⇒ Object
List of aliases for specified fields
49 50 51 |
# File 'lib/ams_layout/delegate_writer.rb', line 49 def aliases @aliases ||= {} end |
#aliases=(data) ⇒ Object
53 54 55 |
# File 'lib/ams_layout/delegate_writer.rb', line 53 def aliases=(data) @aliases = Hash(data) end |
#write(stream, layout) ⇒ Object
Write a class file, based on the the layout.yml, to the provided stream
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ams_layout/delegate_writer.rb', line 61 def write stream, layout stream << header layout.each do |section_label, fields| stream << section(section_label) fields.each do |fld| stream << field(fld[:label], fld[:id], fld[:type]) write_aliases stream, fld[:label], fld[:id], fld[:type] end # fields end # layout stream << end |