Sha256: 38bad90e6b52212ff69a6c5a0b7b79b3aae9f7456cdb655410a5b7fe0dcb16e1

Contents?: true

Size: 1.23 KB

Versions: 97

Compression:

Stored size: 1.23 KB

Contents

module Isomorfeus
  class << self
    def cached_policy_classes
      @cached_array_classes ||= {}
    end

    if RUBY_ENGINE == 'opal'
      def cached_policy_class(class_name)
        return "::#{class_name}".constantize if Isomorfeus.development?
        return cached_policy_classes[class_name] if cached_policy_classes.key?(class_name)
        cached_policy_classes[class_name] = "::#{class_name}".constantize
      end
    else
      def cached_policy_class(class_name)
        return nil unless valid_policy_class_name?(class_name)
        return "::#{class_name}".constantize if Isomorfeus.development?
        return cached_policy_classes[class_name] if cached_policy_classes.key?(class_name)
        cached_policy_classes[class_name] = "::#{class_name}".constantize
      end

      def valid_policy_class_names
        @valid_policy_class_names ||= Set.new
      end

      def valid_policy_class_name?(class_name)
        valid_policy_class_names.include?(class_name)
      end

      def add_valid_policy_class(klass)
        class_name = klass.name
        class_name = class_name.split('>::').last if class_name.start_with?('#<')
        valid_policy_class_names << class_name
      end
    end
  end
end

Version data entries

97 entries across 97 versions & 1 rubygems

Version Path
isomorfeus-policy-23.9.0.rc12 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc11 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc10 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc9 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc8 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc7 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc6 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc5 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc4 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc3 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc2 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.9.0.rc1 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.8.0.rc3 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.8.0.rc2 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.8.0.rc1 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.7.0.rc5 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.7.0.rc4 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.7.0.rc3 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.7.0.rc2 lib/isomorfeus/policy/config.rb
isomorfeus-policy-23.7.0.rc1 lib/isomorfeus/policy/config.rb