Sha256: dfba04661a1f5bf31ddbe416210bb5a3da261846209beba64d31da4211c49f77

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 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 if Snaptable.use_permission
        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

1 entries across 1 versions & 1 rubygems

Version Path
snaptable-0.3.0 lib/snaptable/constructor/base_table.rb