Class: IntegerInheritance::Evaluator

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/integer-inheritance/evaluator.rb

Instance Method Summary collapse

Instance Method Details

#map(*sti_types, to:) ⇒ Object



16
17
18
19
# File 'lib/integer-inheritance/evaluator.rb', line 16

def map(*sti_types, to:)
  full_class_name = to.to_s
  sti_types.each { |t| @mapping[t.to_i] = full_class_name }
end

#with(base_class_name, &block) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/integer-inheritance/evaluator.rb', line 8

def with(base_class_name, &block)
  @mapping = {}
  instance_eval(&block)
  (IntegerInheritance.mappings[base_class_name.to_s] ||= {}).merge!(@mapping)
ensure
  @mapping = nil
end