class RailsAiAdmin::Resource::FieldBuilder
Collects field declarations without consulting the database at boot.
Public Class Methods
Source
# File lib/rails_ai_admin/resource.rb, line 226 def initialize(fields, source: nil) @fields = fields @source = source end
source is the declaring Resource, consulted lazily for column limits.
Public Instance Methods
Source
# File lib/rails_ai_admin/resource.rb, line 231 def field(name, type:, **options) raise ConfigurationError, "Duplicate field #{name}" if @fields.key?(name.to_sym) @fields[name.to_sym] = RailsAiAdmin.field_registry.build(name, type: type, source: @source, **options) end
Source
# File lib/rails_ai_admin/resource.rb, line 240 def readonly(name, type: :text, **options) field(name, type: type, **options.merge(readonly: true)) end
Source
# File lib/rails_ai_admin/resource.rb, line 236 def virtual(name, type:, depends_on:, compute:, **options) field(name, type: type, compute: compute, depends_on: depends_on, **options) end