This avoids a query every time the the list of global action tags is needed (every page load for access control entries and action tag memberships). Move the Model#freeze definition from ActionType to ResourceMethods, as any model using ResourceMethods should precalculate the ubid before being frozen, otherwise #ubid would break for the model.
22 lines
481 B
Ruby
22 lines
481 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../model"
|
|
|
|
class ActionType < Sequel::Model
|
|
include ResourceMethods
|
|
|
|
plugin :static_cache
|
|
|
|
NAME_MAP = Hash.new { |h, k| raise KeyError, "Invalid action type name: #{k}" }
|
|
each { |t| NAME_MAP[t.name] = t.id }
|
|
NAME_MAP.freeze
|
|
end
|
|
|
|
# Table: action_type
|
|
# Columns:
|
|
# id | uuid | PRIMARY KEY
|
|
# name | text | NOT NULL
|
|
# Indexes:
|
|
# action_type_pkey | PRIMARY KEY btree (id)
|
|
# action_type_name_key | UNIQUE btree (name)
|