Sha256: 3012bbd72f55be6c9011254b03d7b85cea031d3b980a6e93905fabcba42d91cc
Contents?: true
Size: 1.04 KB
Versions: 41
Compression:
Stored size: 1.04 KB
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.to_s => %i[index show update create destroy] elsif model.class == Hash @singleton_models[project][role].merge! model.to_s end end @singleton_models = @singleton_models.with_indifferent_access end def singleton_models_for(project, role: :admin) project = project.underscore.to_sym unless project.is_a? Symbol 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
41 entries across 41 versions & 1 rubygems
Version | Path |
---|---|
tramway-admin-1.32.2.4 | lib/tramway/admin/singleton_models.rb |