Class: SourceMonitor::Configuration::Models
- Inherits:
-
Object
- Object
- SourceMonitor::Configuration::Models
- 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
-
#table_name_prefix ⇒ Object
Returns the value of attribute table_name_prefix.
Instance Method Summary collapse
- #for(name) ⇒ Object
-
#initialize ⇒ Models
constructor
A new instance of Models.
Constructor Details
#initialize ⇒ Models
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_prefix ⇒ Object
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
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 |