class Aerogel::Admin::TableBuilder
TableBuilder
constructs and displays a table populated with data obtained from passed object.
Example:
table User.all do column :full_name column :roles end
Constants
- DEFAULT_OPTIONS
Attributes
columns[RW]
object[RW]
options[RW]
style[RW]
Public Class Methods
new( object, options = {}, &block )
click to toggle source
Calls superclass method
# File lib/aerogel/admin/table_builder.rb, line 22 def initialize( object, options = {}, &block ) super( &block ) self.object = object self.options = DEFAULT_OPTIONS.deep_merge( options ) self.style = self.options[:style] self.columns = [] end
Public Instance Methods
column( *args, &block )
click to toggle source
# File lib/aerogel/admin/table_builder.rb, line 30 def column( *args, &block ) self.columns << Column.new( self, *args, &block ) nil end
html_params()
click to toggle source
Renders html params for <table …>
# File lib/aerogel/admin/table_builder.rb, line 45 def html_params attrs = @options[:html_params].dup attrs.merge!({ # :action => @options[:action] }) attrs.map{|n, v| v.nil? ? "#{n}" : "#{n}=\"#{v}\""}.join(" ") end
template( name )
click to toggle source
# File lib/aerogel/admin/table_builder.rb, line 35 def template( name ) "admin/table_builder/#{style}/#{name}".to_sym end
wrap( content )
click to toggle source
# File lib/aerogel/admin/table_builder.rb, line 39 def wrap( content ) erb template("table.html"), locals: { table: self }, layout: false end