Module: DataMapper::NamingConventions::Field::FQN
- Defined in:
- lib/dm-core/support/naming_conventions.rb
Overview
module Underscored
Class Method Summary collapse
Class Method Details
.call(property) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/dm-core/support/naming_conventions.rb', line 82 def self.call(property) model, name = property.model, property.name fk_names = model.relationships.inject([]) { |names, rel| if rel.respond_to?(:required?) names + rel.source_key.map(&:name) else names end } return name.to_s if fk_names.include?(name) storage_name = model.storage_name(property.repository_name) "#{DataMapper::Inflector.singularize(storage_name)}_#{name}" end |