Files
ubicloud/model/action_type.rb
Jeremy Evans 718370f4c9 Convert ResourceMethods to a plugin
Allow plugin to take an etc_type keyword argument for using the
TYPE_ETC ubid type, and remove the separate definitions in every
model that uses the TYPE_ETC ubid type.

This was the cleanest way to DRY things up.  You cannot extend
the models with a module to do this before including ResourceMethods,
because then ResourceMethods::ClassMethods will override it, and
you cannot extend the models with a module to do this after
including ResourceMethods, because the inclusion will not work
correctly due to the eager definition of @ubid_format.

Best reviewed without whitespace differences.
2025-06-04 04:55:45 +09:00

22 lines
480 B
Ruby

# frozen_string_literal: true
require_relative "../model"
class ActionType < Sequel::Model
plugin 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)