Sha256: c671caeba26d2f84c8bdc5adc54a2b13416e29ca8f77df2fd44f6ed5efd6dcd9

Contents?: true

Size: 1.19 KB

Versions: 15

Compression:

Stored size: 1.19 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

15 entries across 15 versions & 1 rubygems

Version Path
isomorfeus-policy-1.0.0.zeta25 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta24 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta23 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta22 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta21 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta20 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta19 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta18 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta17 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta16 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta15 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta14 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta13 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta12 lib/isomorfeus/policy/config.rb
isomorfeus-policy-1.0.0.zeta11 lib/isomorfeus/policy/config.rb