Class: SourceMonitor::Configuration::Models

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/configuration/models.rb

Constant Summary collapse

MODEL_KEYS =
{
  source: :source,
  item: :item,
  fetch_log: :fetch_log,
  scrape_log: :scrape_log,
  health_check_log: :health_check_log,
  item_content: :item_content,
  log_entry: :log_entry
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModels

Returns a new instance of Models.



18
19
20
21
# File 'lib/source_monitor/configuration/models.rb', line 18

def initialize
  @table_name_prefix = "sourcemon_"
  @definitions = MODEL_KEYS.transform_values { ModelDefinition.new }
end

Instance Attribute Details

#table_name_prefixObject

Returns the value of attribute table_name_prefix.



16
17
18
# File 'lib/source_monitor/configuration/models.rb', line 16

def table_name_prefix
  @table_name_prefix
end

Instance Method Details

#for(name) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
# File 'lib/source_monitor/configuration/models.rb', line 27

def for(name)
  key = name.to_sym
  definition = @definitions[key]
  raise ArgumentError, "Unknown model #{name.inspect}" unless definition

  definition
end