module Attractor
Constants
- VERSION
Public Class Methods
all_registered_calculators(options = {})
click to toggle source
# File lib/attractor.rb, line 45 def all_registered_calculators(options = {}) Hash[@registry_entries.map do |type, entry| [type, entry.calculator_class.new(**options)] if entry.detector_class.new.detect end.compact] end
calculators_for_type(type, **options)
click to toggle source
# File lib/attractor.rb, line 37 def calculators_for_type(type, **options) registry_entry_for_type = @registry_entries[type] return {type => registry_entry_for_type.calculator_class.new(**options)} if type all_registered_calculators(**options) end
clear()
click to toggle source
# File lib/attractor.rb, line 29 def clear Cache.clear end
init(calculators)
click to toggle source
# File lib/attractor.rb, line 24 def init(calculators) calculators ||= all_registered_calculators calculators.to_a.map(&:last).each(&:calculate) end
register(registry_entry)
click to toggle source
# File lib/attractor.rb, line 33 def register(registry_entry) @registry_entries[registry_entry.type] = registry_entry end
Private Instance Methods
all_registered_calculators(options = {})
click to toggle source
# File lib/attractor.rb, line 45 def all_registered_calculators(options = {}) Hash[@registry_entries.map do |type, entry| [type, entry.calculator_class.new(**options)] if entry.detector_class.new.detect end.compact] end
calculators_for_type(type, **options)
click to toggle source
# File lib/attractor.rb, line 37 def calculators_for_type(type, **options) registry_entry_for_type = @registry_entries[type] return {type => registry_entry_for_type.calculator_class.new(**options)} if type all_registered_calculators(**options) end
clear()
click to toggle source
# File lib/attractor.rb, line 29 def clear Cache.clear end
init(calculators)
click to toggle source
# File lib/attractor.rb, line 24 def init(calculators) calculators ||= all_registered_calculators calculators.to_a.map(&:last).each(&:calculate) end
register(registry_entry)
click to toggle source
# File lib/attractor.rb, line 33 def register(registry_entry) @registry_entries[registry_entry.type] = registry_entry end