Sha256: 15724b4dd5cad5eb2cd64031d0856e2c13baed7b15a17137e5672306509f4c94

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

module Workarea
  module Admin
    class ChangesetSummaryViewModel < ApplicationViewModel
      delegate :model_name, to: :model_class

      def count
        model['count']
      end

      def type
        model['_id']
      end

      def type_filter
        search_model&.type || model_name.param_key
      end

      def label
        type_filter.titleize.pluralize(count)
      end

      def searchable?
        search_model.present?
      end

      private

      def model_class
        @model_class ||= type.constantize
      end

      def search_model
        return @search_model if defined?(@serch_model)

        @search_model = Search::Admin.for(model_class.new)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/view_models/workarea/admin/changeset_summary_view_model.rb
workarea-admin-3.5.26 app/view_models/workarea/admin/changeset_summary_view_model.rb
workarea-admin-3.5.25 app/view_models/workarea/admin/changeset_summary_view_model.rb