Class: ActiveItem::Configuration
- Inherits:
-
Object
- Object
- ActiveItem::Configuration
- Defined in:
- lib/active_item/configuration.rb
Overview
Holds global settings for ActiveItem including logger, table prefix, and environment. Used to derive DynamoDB table names from model class names.
Instance Attribute Summary collapse
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#table_prefix ⇒ Object
Returns the value of attribute table_prefix.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#table_name_for(class_name) ⇒ Object
Generates table name from model class name using configured prefix/env Pattern: prefix-env-model-name-pluralized If no prefix configured, just uses the model name pluralized+dasherized.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 |
# File 'lib/active_item/configuration.rb', line 11 def initialize @logger = NullLogger.new @table_prefix = nil @environment = nil end |
Instance Attribute Details
#environment ⇒ Object
Returns the value of attribute environment.
9 10 11 |
# File 'lib/active_item/configuration.rb', line 9 def environment @environment end |
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/active_item/configuration.rb', line 9 def logger @logger end |
#table_prefix ⇒ Object
Returns the value of attribute table_prefix.
9 10 11 |
# File 'lib/active_item/configuration.rb', line 9 def table_prefix @table_prefix end |
Instance Method Details
#table_name_for(class_name) ⇒ Object
Generates table name from model class name using configured prefix/env Pattern: prefix-env-model-name-pluralized If no prefix configured, just uses the model name pluralized+dasherized
20 21 22 23 24 |
# File 'lib/active_item/configuration.rb', line 20 def table_name_for(class_name) base = class_name.underscore.dasherize.pluralize parts = [table_prefix, environment, base].compact parts.join('-') end |