Sha256: fedd9519a7217f0d57e963a127994b0934ee1df240b49a5857aad8db25346bfb

Contents?: true

Size: 254 Bytes

Versions: 3

Compression:

Stored size: 254 Bytes

Contents

require 'facet/string/demodulize'
require 'facet/string/underscore'
class String
  def foreign_key(separate_class_name_and_id_with_underscore = true)
    self.demodulize.underscore + ( separate_class_name_and_id_with_underscore ? "_id" : "id")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-0.7.0 lib/facet/string/foreign_key.rb
facets-0.7.1 lib/facet/string/foreign_key.rb
facets-0.7.2 lib/facet/string/foreign_key.rb