Sha256: a8b89546ed2631c10c7c5f9b63d224cc2580ed7661cb5f55406e7cba408b564e

Contents?: true

Size: 782 Bytes

Versions: 3

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module CustomFields
  module Types
    module RelationshipDefault
      module Field
        extend ActiveSupport::Concern

        included do
          field :class_name
          field :inverse_of
          field :order_by

          validates_presence_of :class_name,                  if: :is_relationship?
          validate              :ensure_class_name_security,  if: :is_relationship?

          def is_relationship?
            method_name = :"#{type}_is_relationship?"
            respond_to?(method_name) && send(method_name)
          end

          protected

          def ensure_class_name_security
            true
            # FIXME: to be overridden in the target application
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
custom_fields-2.14.0.alpha1 lib/custom_fields/types/relationship_default.rb
custom_fields-2.13.1 lib/custom_fields/types/relationship_default.rb
custom_fields-2.13.0 lib/custom_fields/types/relationship_default.rb