Class: DatabaseConsistency::ReportBuilder
- Inherits:
-
Object
- Object
- DatabaseConsistency::ReportBuilder
- Defined in:
- lib/database_consistency/report_builder.rb
Overview
:nodoc:
Class Method Summary collapse
-
.define(klass, *attrs) ⇒ Object
rubocop:disable Metrics/MethodLength.
Class Method Details
.define(klass, *attrs) ⇒ Object
rubocop:disable Metrics/MethodLength
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/database_consistency/report_builder.rb', line 5 def self.define(klass, *attrs) # rubocop:disable Metrics/MethodLength Class.new(klass) do attr_reader(*attrs) class_eval(" def initialize(\#{attrs.map { |attr| \"\#{attr}:\" }.join(', ')}, **opts)\n super(**opts) if opts.any?\n \#{attrs.map { |attr| \"@\#{attr} = \#{attr}\" }.join(\"\\n\")}\n end\n\n def to_h\n h = defined?(super) ? super : {}\n \#{attrs.map { |attr| \"h[\#{attr}] = \#{attr}\" }.join(\"\\n\")}\n h\n end\n DEF\n end\nend\n", __FILE__, __LINE__ + 1) |