module JpMunicipality::HasMunicipality::ClassMethods

Public Instance Methods

has_municipality(foreign_key = :municipality_code, options = {}) click to toggle source
# File lib/jp_municipality/has_municipality.rb, line 6
def has_municipality(foreign_key = :municipality_code, options = {})
  options.reverse_merge!({
    as: :municipality,
    optional: true,
  })
  belongs_to options[:as], foreign_key: foreign_key, optional: options[:optional],
    class_name: 'JpMunicipality::Municipality'
end