Class: ActiveItem::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

def initialize
  @logger = NullLogger.new
  @table_prefix = nil
  @environment = nil
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



7
8
9
# File 'lib/active_item/configuration.rb', line 7

def environment
  @environment
end

#loggerObject

Returns the value of attribute logger.



7
8
9
# File 'lib/active_item/configuration.rb', line 7

def logger
  @logger
end

#table_prefixObject

Returns the value of attribute table_prefix.



7
8
9
# File 'lib/active_item/configuration.rb', line 7

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



18
19
20
21
22
# File 'lib/active_item/configuration.rb', line 18

def table_name_for(class_name)
  base = class_name.underscore.dasherize.pluralize
  parts = [table_prefix, environment, base].compact
  parts.join('-')
end