Sha256: 29e5a383307af3081ab6d89016debafc402b5b332048e45b872692037b23fefd
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
module DataMapper # Use these modules to establish naming conventions. # The default is UnderscoredAndPluralized. # You assign a naming convention like so: # # repository(:default).adapter.resource_naming_convention = NamingConventions::Underscored # # You can also easily assign a custom convention with a Proc: # # repository(:default).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. # DataMapper.setup(name, uri) returns the Adapter for convenience, so you can # use code like this: # # adapter = DataMapper.setup(:default, "mock://localhost/mock") # adapter.resource_naming_convention = DataMapper::NamingConventions::Underscored module NamingConventions module UnderscoredAndPluralized def self.call(value) Extlib::Inflection.pluralize(Extlib::Inflection.underscore(value)).gsub('/','_') end end # module UnderscoredAndPluralized module UnderscoredAndPluralizedWithoutModule def self.call(value) Extlib::Inflection.pluralize(Extlib::Inflection.underscore(Extlib::Inflection.demodulize(value))) end end # module UnderscoredAndPluralizedWithoutModule module Underscored def self.call(value) Extlib::Inflection.underscore(value) end end # module Underscored module Yaml def self.call(value) Extlib::Inflection.pluralize(Extlib::Inflection.underscore(value)) + ".yaml" end end # module Yaml end # module NamingConventions end # module DataMapper
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dm-core-0.9.2 | lib/dm-core/naming_conventions.rb |
dm-core-0.9.3 | lib/dm-core/naming_conventions.rb |