Module: Motor::BuildSchema

Defined in:
lib/motor/build_schema.rb,
lib/motor/build_schema/utils.rb,
lib/motor/build_schema/defaults.rb,
lib/motor/build_schema/load_from_rails.rb,
lib/motor/build_schema/apply_permissions.rb,
lib/motor/build_schema/find_display_column.rb,
lib/motor/build_schema/merge_schema_configs.rb,
lib/motor/build_schema/adjust_devise_model_schema.rb,
lib/motor/build_schema/active_storage_attachment_schema.rb

Defined Under Namespace

Modules: ActiveStorageAttachmentSchema, AdjustDeviseModelSchema, ApplyPermissions, ColumnAccessTypes, ColumnSources, ColumnTypes, Defaults, FindDisplayColumn, LoadFromRails, MergeSchemaConfigs, Utils

Constant Summary collapse

SEARCHABLE_COLUMN_TYPES =
%i[citext text string bitstring].freeze
DEFAULT_TYPE =
'default'
DEFAULT_ICON =
'database'
COLUMN_NAME_ACCESS_TYPES =
{
  id: ColumnAccessTypes::READ_ONLY,
  created_at: ColumnAccessTypes::READ_ONLY,
  created_on: ColumnAccessTypes::READ_ONLY,
  inserted_at: ColumnAccessTypes::READ_ONLY,
  updated_at: ColumnAccessTypes::READ_ONLY,
  updated_on: ColumnAccessTypes::READ_ONLY,
  modified_at: ColumnAccessTypes::READ_ONLY,
  deleted_at: ColumnAccessTypes::READ_ONLY
}.with_indifferent_access.freeze
COLUMN_DEFAULTS =
{
  access_type: ColumnAccessTypes::READ_WRITE,
  column_source: ColumnSources::TABLE,
  default_value: nil,
  reference: nil,
  format: {},
  validators: []
}.with_indifferent_access
ACTION_DEFAULTS =
{
  visible: true,
  preferences: {}
}.with_indifferent_access
TAB_DEFAULTS =
{
  visible: true,
  tab_type: DEFAULT_TYPE,
  preferences: {}
}.with_indifferent_access
SCOPE_DEFAULTS =
{
  visible: true,
  scope_type: DEFAULT_TYPE,
  preferences: {}
}.with_indifferent_access
ASSOCIATION_DEFAULTS =
{
  visible: true,
  icon: DEFAULT_ICON,
  options: {}
}.with_indifferent_access

Class Method Summary collapse

Class Method Details

.call(cache_keys = {}, current_ability = nil) ⇒ Object


96
97
98
99
100
101
102
# File 'lib/motor/build_schema.rb', line 96

def call(cache_keys = {}, current_ability = nil)
  schema = LoadFromRails.call
  schema = MergeSchemaConfigs.call(schema, cache_keys)
  schema = ApplyPermissions.call(schema, current_ability) if current_ability

  ReorderSchema.call(schema, cache_keys)
end