Sha256: 0d3455580370520fd9f7ae8915a5419c1612a9a0c520ede6ea353284b413dabe

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module ActiveList
  module Definition
    class AbstractColumn
      attr_reader :table, :name, :id, :options, :condition

      def initialize(table, name, options = {})
        @table   = table
        @name    = name.to_sym
        @options = options
        @hidden  = !!@options.delete(:hidden)
        @condition = @options.delete(:condition)
        @id = 'c' + @table.new_column_id # ActiveList.new_uid
      end

      def header_code
        raise NotImplementedError, "#{self.class.name}#header_code is not implemented."
      end

      def hidden?
        @hidden
      end

      def sortable?
        false
      end

      def exportable?
        false
      end

      def computable?
        false
      end

      # Unique identifier of the column in the application
      def unique_id
        "#{@table.name}-#{@name}"
      end

      # Uncommon but simple identifier for CSS class uses
      def short_id
        @id
      end

      alias sort_id name

      def check_options!(options, *keys)
        for key in options.keys
          raise ArgumentError, "Key :#{key} is unexpected. (Expecting: #{keys.to_sentence})"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_list-8.1.0 lib/active_list/definition/abstract_column.rb
active_list-7.3.0 lib/active_list/definition/abstract_column.rb
active_list-8.0.0 lib/active_list/definition/abstract_column.rb
active_list-7.2.0 lib/active_list/definition/abstract_column.rb