Sha256: 307aa755ae781e7e6fdcecf11ee94f03add37831d9bd517326ee74686f741f45
Contents?: true
Size: 999 Bytes
Versions: 5
Compression:
Stored size: 999 Bytes
Contents
# frozen_string_literal: true module Tramway::Admin::SingletonModels def set_singleton_models(*models, project:, role: :admin) @singleton_models ||= {} @singleton_models[project] ||= {} @singleton_models[project][role] ||= {} models.each do |model| if model.class == Class @singleton_models[project][role].merge! model => [ :index, :show, :update, :create, :destroy ] elsif model.class == Hash @singleton_models[project][role].merge! model end end @singleton_models = @singleton_models.with_indifferent_access end def singleton_models_for(project, role: :admin) models = get_models_by_key(@singleton_models, project, role) if project_is_engine?(project) models += engine_class(project).dependencies.map do |dependency| @singleton_models&.dig(dependency, role)&.keys end.flatten.compact end models end def singleton_models(role:) models_array models_type: :singleton, role: role end end
Version data entries
5 entries across 5 versions & 1 rubygems