Sha256: 2de6760d2ae2bbfaedc3f4f0f3728a4416e559e546d0dd87b61fb5639347a0d9

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

module DiningTable
  
  module Columns

    class ActionsColumn < Column
      
      def value(object)
        if block
          @incremental_value = ''.html_safe
          @current_object = object
          self.instance_eval(&block)
          @incremental_value
        end
      end
      
      private
      
        def action(&block)
          action_value = table.instance_exec(@current_object, &block)
          @incremental_value += action_value.to_s if action_value && action_value.respond_to?(:to_s)
        end

        # offer methods normally available on Table that could be used by the action-column block
        [ :h, :helpers, :collection, :index, :presenter ].each do |method|
          self.class_eval <<-eos, __FILE__, __LINE__+1
            def #{method}(*args)
              table.#{method}
            end
          eos
        end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dining-table-1.1.3 lib/dining-table/columns/actions_column.rb
dining-table-1.1.2 lib/dining-table/columns/actions_column.rb