Class: Datory::Attributes::Descriptor
- Inherits:
-
Object
- Object
- Datory::Attributes::Descriptor
- Defined in:
- lib/datory/attributes/descriptor.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#describe(service_class_name:, collection_of_attributes:) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Class Method Details
.describe ⇒ Object
6 7 8 |
# File 'lib/datory/attributes/descriptor.rb', line 6 def self.describe(...) new.describe(...) end |
Instance Method Details
#describe(service_class_name:, collection_of_attributes:) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/datory/attributes/descriptor.rb', line 10 def describe(service_class_name:, collection_of_attributes:) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize headings = [] rows = [] headings << "Attribute" headings << "From" headings << "To" headings << "As" headings << "Include" if collection_of_attributes.include_class_exist? collection_of_attributes.each do |attribute| row = [] include_class = attribute.to.include_class.presence || attribute.from.type row << attribute.from.name row << attribute.from.type row << attribute.to.name row << attribute.to.type row << (include_class if include_class <= Datory::Base) if collection_of_attributes.include_class_exist? rows << row end Datory::Console.print_table(title: service_class_name, headings: headings.uniq, rows:) end |