Class: Togls::RuleTypeRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/togls/rule_type_repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(drivers) ⇒ RuleTypeRepository

Returns a new instance of RuleTypeRepository.



3
4
5
# File 'lib/togls/rule_type_repository.rb', line 3

def initialize(drivers)
  @drivers = drivers
end

Instance Method Details

#get_klass(type_id) ⇒ Object



24
25
26
27
28
# File 'lib/togls/rule_type_repository.rb', line 24

def get_klass(type_id)
  klass_string = fetch_klass_string(type_id.to_s)
  return Object.const_get(klass_string) if klass_string
  klass_string
end

#get_type_id(klass) ⇒ Object



30
31
32
# File 'lib/togls/rule_type_repository.rb', line 30

def get_type_id(klass)
  fetch_type_id(klass.to_s)
end

#include?(type_id) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/togls/rule_type_repository.rb', line 14

def include?(type_id)
  type = get_klass(type_id)
  type ? true : false
end

#include_klass?(klass) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/togls/rule_type_repository.rb', line 19

def include_klass?(klass)
  type = get_type_id(klass)
  type ? true : false
end

#store(type_id, klass) ⇒ Object



7
8
9
10
11
12
# File 'lib/togls/rule_type_repository.rb', line 7

def store(type_id, klass)
  @drivers.each do |driver|
    driver.store(type_id.to_s, klass.to_s, klass.title, klass.description,
                 klass.target_type.to_s)
  end
end