Sha256: 4f0fa7f31f2f7e795b0ee9ff58c85326f9d5b1b752995d3f85eeb601fd15478c
Contents?: true
Size: 1.06 KB
Versions: 29
Compression:
Stored size: 1.06 KB
Contents
# typed: true # 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
29 entries across 29 versions & 1 rubygems