Sha256: 2fe3da3b8b626372c53f23f19d04d9e98b1b6fc4ff4496b8b9ee131462a2ec63

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

module Trestle
  class Table
    class Row
      attr_reader :options, :block

      def initialize(options={}, &block)
        @options = options
        @block = block if block_given?
      end

      def renderer(template)
        Renderer.new(self, template)
      end

      class Renderer
        def initialize(row, template)
          @row, @template = row, template
        end

        def options(instance)
          options = Trestle::Options.new(data: { url: @template.admin_url_for(instance) })
          options.merge!(@row.options)
          options.merge!(@template.instance_exec(instance, &@row.block)) if @row.block
          options
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trestle-0.8.2 lib/trestle/table/row.rb
trestle-0.8.0 lib/trestle/table/row.rb