Sha256: 63bdd22f439dc1b943cc1bf026281ab0e81ec234f18378a3dd3c71170a7d2451
Contents?: true
Size: 1.06 KB
Versions: 10
Compression:
Stored size: 1.06 KB
Contents
# typed: ignore # Copyright (c) 2015 Sqreen. All Rights Reserved. # Please refer to our terms for more information: https://www.sqreen.com/terms.html module Sqreen module Actions # Where the actions are stored # The current ones are stored in Repository.current class Repository def initialize @indexes = Hash[Base.known_subclasses.map do |clazz| [clazz.type_name, clazz.new_index] end] end def add(params, action) @indexes[action.class.type_name].index(params || {}, action) end # type is either a class or a type name def get(type, key) type = type.type_name if type.class == Class @indexes[type].actions_matching key end singleton_class.class_eval do attr_reader :current def current=(new_inst) raise 'nil is unacceptable' if new_inst.nil? @current = new_inst end def clear self.current = Repository.new end end # initialize current to empty repository clear end end end
Version data entries
10 entries across 10 versions & 1 rubygems