Sha256: d9ebb697cbe88692dd2f236d41eadb4057ea13f2bf9a16692f28ba2ec99cca7e

Contents?: true

Size: 765 Bytes

Versions: 9

Compression:

Stored size: 765 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Suggestions
      class DatabaseValue < Base
        attr_reader :model, :column

        delegate :to_param, to: :@attribute_type

        def initialize(name:, type:, model:, column:, value:)
          super(value)

          @attribute_type = type
          @model = model
          @column = column
          @name = name
        end

        def type
          :database_value
        end

        using Tables::Collection::Type::Helpers::Extensions

        def value
          if @attribute_type.multiple? && @value.is_a?(Array) && @value.length == 1
            to_param(@value.first)
          else
            to_param(@value)
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katalyst-tables-3.6.2 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.6.1 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.6.0 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.5.5 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.5.4 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.5.3 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.5.2 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.5.1 app/models/katalyst/tables/suggestions/database_value.rb
katalyst-tables-3.5.0 app/models/katalyst/tables/suggestions/database_value.rb