Sha256: e105a51a514331f749840dfbff93090f14f42fd6d148ff66812c8873380e9824
Contents?: true
Size: 732 Bytes
Versions: 4
Compression:
Stored size: 732 Bytes
Contents
module DynamicFields class Attribute < ApplicationRecord DEFAULT_FIELD_TYPE = :string AVAILABLE_ATTRIBUTE_TYPES = %i[ string boolean integer ].freeze belongs_to :record, polymorphic: true validates :name, presence: true validates :name, uniqueness: { scope: [:record_type, :record_id] } class << self def attribute_class_for_attribute_type(attribute_type) case attribute_type when :string return "DynamicFields::Attribute::StringAttribute" when :integer return "DynamicFields::Attribute::IntegerAttribute" when :boolean return "DynamicFields::Attribute::BooleanAttribute" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems