From 8e8cfa6c52ff8fc2a655b768db5baafed40c1a2d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 19 Sep 2017 15:20:01 +0200 Subject: Add `ModelAttribute` This new class will allow us to generate a list of all editable fields in all our models including the type of each field. We need this for Compliance Control, in order to get a list of fields or models & fields that can be selected to validate a given model validation check. The crucial bits here are the models, fields, and the types of those fields. These need to be defined (manually at least to begin with), accessible, and filterable. Refs #4401 --- lib/model_attribute.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/model_attribute.rb (limited to 'lib/model_attribute.rb') diff --git a/lib/model_attribute.rb b/lib/model_attribute.rb new file mode 100644 index 000000000..be5caea94 --- /dev/null +++ b/lib/model_attribute.rb @@ -0,0 +1,17 @@ +class ModelAttribute + cattr_reader :all + + @@all = [] + + attr_reader :klass, :name, :data_type + + def self.define(klass, name, data_type) + @@all << new(klass, name, data_type) + end + + def initialize(klass, name, data_type) + @klass = klass + @name = name + @data_type = data_type + end +end -- cgit v1.2.3