Module: Ardm::NamingConventions
- Defined in:
- lib/ardm/support/naming_conventions.rb
Overview
Use these modules to establish naming conventions. The default is UnderscoredAndPluralized. You assign a naming convention like so:
connection.adapter.resource_naming_convention = NamingConventions::Resource::Underscored
You can also easily assign a custom convention with a Proc:
connection.adapter.resource_naming_convention = lambda do |value|
'tbl' + value.camelize(true)
end
Or by simply defining your own module in NamingConventions that responds to ::call.
NOTE: It’s important to set the convention before accessing your models since the resource_names are cached after first accessed. Ardm.setup(name, uri) returns the Adapter for convenience, so you can use code like this:
adapter = Ardm.setup(:default, 'mock://localhost/mock')
adapter.resource_naming_convention = NamingConventions::Resource::Underscored