Sha256: ba5f84ade8192b46fcac00bfbed39c148c440300d890de4a6bc18a801e1e85b0

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'snaptable/constructor/sortable'
require 'snaptable/constructor/collection'
require 'snaptable/constructor/renderer'

module Snaptable
  module Constructor 

      class BaseTable < SimpleDelegator
        include Sortable
        include Collection
        include Renderer

        def initialize(parent, collection = nil, options = {})
          super(parent)
          @collection = collection
          @options = options
          @token = stored_token
        end

        def options
          @options
        end

        def column_names
          model.column_names
        end

        def url(e)
          e.id
        end

        def values(element)
          attributes.map do |attribute|
            if attribute.is_a? Symbol 
              element.send(attribute)
            else
              element.send(*attribute.keys).send(*attribute.values)
            end.to_s
          end
        end

        private

        def stored_token
          session[:token] = params[:token] if params[:token]
          return session[:token]
        end
      end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
snaptable-0.2.1 lib/snaptable/constructor/base_table.rb
snaptable-0.2.0 lib/snaptable/constructor/base_table.rb