Class: ActiveItem::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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

#environmentObject

Returns the value of attribute environment.



9
10
11
# File 'lib/active_item/configuration.rb', line 9

def environment
  @environment
end

#loggerObject

Returns the value of attribute logger.



9
10
11
# File 'lib/active_item/configuration.rb', line 9

def logger
  @logger
end

#table_prefixObject

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