Class: Sqreen::Actions::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/sqreen/actions/repository.rb

Overview

Where the actions are stored The current ones are stored in Repository.current

Instance Method Summary collapse

Constructor Details

#initializeRepository

Returns a new instance of Repository.



11
12
13
14
15
# File 'lib/sqreen/actions/repository.rb', line 11

def initialize
  @indexes = Hash[Base.known_subclasses.map do |clazz|
    [clazz.type_name, clazz.new_index]
  end]
end

Instance Method Details

#add(params, action) ⇒ Object



17
18
19
# File 'lib/sqreen/actions/repository.rb', line 17

def add(params, action)
  @indexes[action.class.type_name].index(params || {}, action)
end

#get(type, key) ⇒ Object

type is either a class or a type name



22
23
24
25
# File 'lib/sqreen/actions/repository.rb', line 22

def get(type, key)
  type = type.type_name if type.class == Class
  @indexes[type].actions_matching key
end