lib/trestle/table/row.rb in trestle-0.8.2 vs lib/trestle/table/row.rb in trestle-0.8.3

- old
+ new

@@ -1,28 +1,36 @@ module Trestle class Table class Row - attr_reader :options, :block + attr_reader :table, :options, :block - def initialize(options={}, &block) - @options = options + def initialize(table, options={}, &block) + @table, @options = table, options @block = block if block_given? end def renderer(template) Renderer.new(self, template) end class Renderer + delegate :table, to: :@row + def initialize(row, template) @row, @template = row, template end def options(instance) - options = Trestle::Options.new(data: { url: @template.admin_url_for(instance) }) + options = Trestle::Options.new + options.merge!(data: { url: admin_url_for(instance) }) if table.options[:admin] options.merge!(@row.options) options.merge!(@template.instance_exec(instance, &@row.block)) if @row.block options + end + + protected + def admin_url_for(instance) + @template.admin_url_for(instance, admin: table.options[:admin]) end end end end end