Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Add NamingConventions::Field::FQN
Browse files Browse the repository at this point in the history
Given

* a model with storage_name = ‘accounts’
* a property with name = ‘name’

returns ‘account_name’

This is useful for defining database schemas which need minimal
renaming for natural joins
  • Loading branch information
snusnu committed May 3, 2014
1 parent a74f9ec commit b8bec55
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/dm-core/support/naming_conventions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def self.call(property)
end
end # module Underscored

module FQN
def self.call(property)
storage_name = property.model.storage_name(property.repository_name)
"#{DataMapper::Inflector.singularize(storage_name)}_#{property.name}"
end
end # module FQN

module Yaml
def self.call(property)
"#{DataMapper::Inflector.pluralize(DataMapper::Inflector.underscore(property.name.to_s))}.yaml"
Expand Down

0 comments on commit b8bec55

Please sign in to comment.