Sha256: 9ae9096e5575a4c00b962852563b976cafd887790201e8b43aa5d44f2946d0b1

Contents?: true

Size: 648 Bytes

Versions: 2

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true

module Rows::Model
  def model_class
    @_model_class ||= self.class.model_class ||
                      Kernel.const_get(params[:controller].classify)
  end

  if Rails::VERSION::MAJOR > 3
    def model_name
      @_model_name ||= model_class.model_name.name
    end

    def model_symbol
      @_model_symbol ||= model_class.model_name.singular
    end
  else
    def model_name
      @_model_name ||= model_class.name
    end

    def model_symbol
      @_model_symbol ||= model_name.underscore.tr('/', '_')
    end
  end

  def model_symbol_plural
    @_model_symbol_plural ||= model_symbol.pluralize
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rows_controller-3.0.5 lib/rows/model.rb
rows_controller-3.0.4 lib/rows/model.rb