From 4b559fb74e676033886ba3db5d3b7415032684a5 Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Mon, 17 May 2021 01:21:55 +0530 Subject: [PATCH] specify serializable attributes in field model --- lib/custom_wizard/field.rb | 64 +++++++++++++------ .../custom_wizard/wizard_field_serializer.rb | 18 +----- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/lib/custom_wizard/field.rb b/lib/custom_wizard/field.rb index 7d6ee940..7912251f 100644 --- a/lib/custom_wizard/field.rb +++ b/lib/custom_wizard/field.rb @@ -4,27 +4,27 @@ class CustomWizard::Field include ActiveModel::SerializerSupport def self.attributes - %i{ - raw - id - index - type - step - required - value - description - image - key - validations - min_length - max_length - char_counter - file_types - format - limit - property - content - } + %i{ + raw + id + index + type + step + required + value + description + image + key + validations + min_length + max_length + char_counter + file_types + format + limit + property + content + } end def self.accessible_attributes @@ -44,6 +44,28 @@ class CustomWizard::Field attributes - accessible_attributes - excluded_attributes end + def self.serializable_attributes + %i{ + id + index + type + required + value + label + placeholder + description + image + file_types + format + limit + property + content + validations + max_length + char_counter + } + end + attr_reader *readonly_attributes attr_accessor *accessible_attributes diff --git a/serializers/custom_wizard/wizard_field_serializer.rb b/serializers/custom_wizard/wizard_field_serializer.rb index 46b46c19..16563618 100644 --- a/serializers/custom_wizard/wizard_field_serializer.rb +++ b/serializers/custom_wizard/wizard_field_serializer.rb @@ -8,23 +8,7 @@ ## class CustomWizard::FieldSerializer < ::ApplicationSerializer - attributes :id, - :index, - :type, - :required, - :value, - :label, - :placeholder, - :description, - :image, - :file_types, - :format, - :limit, - :property, - :content, - :validations, - :max_length, - :char_counter + attributes *CustomWizard::Field.serializable_attributes def id object.id