Sha256: 21d00ce2d05334641074ce0190ed95aad7543596b1014f0594f48fa627df9cb2

Contents?: true

Size: 478 Bytes

Versions: 9

Compression:

Stored size: 478 Bytes

Contents

require 'mks/common/methodresponse'
require 'mks/common/util'
module LookupList
  extend ActiveSupport::Concern

  def lookup
    clazz = get_model
    lookups = clazz.order(:name).select('id, name')
    response = Mks::Common::MethodResponse.new(true, nil, lookups, nil)
    render json: response
  end

  private

  def get_model
    get_model_name.constantize
  end

  def get_model_name
    name = self.class.to_s
    name.slice!('Controller')
    name.singularize
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
logistics_core-21.11.2 app/controllers/concerns/lookup_list.rb
logistics_core-21.11.1 app/controllers/concerns/lookup_list.rb
logistics_core-21.08.1 app/controllers/concerns/lookup_list.rb
logistics_core-21.03.1 app/controllers/concerns/lookup_list.rb
logistics_core-20.10.3 app/controllers/concerns/lookup_list.rb
logistics_core-20.10.2 app/controllers/concerns/lookup_list.rb
logistics_core-20.10.1 app/controllers/concerns/lookup_list.rb
logistics_core-20.9.1 app/controllers/concerns/lookup_list.rb
logistics_core-20.8.1 app/controllers/concerns/lookup_list.rb