class Presentation::Grid

TODO: ability to render a hash TODO: custom css classes for rows and/or cells TODO: document or complain for required options – id and fields TODO: make fields= accept an ActiveRecord::Base.columns array for a default field set

Attributes

id[RW]

The id for this presentation. Required.

title[W]

The display title for this presentation. Will default based on the id.

Public Instance Methods

colspan() click to toggle source
# File lib/presentation/grid.rb, line 38
def colspan
  @colspan ||= fields.size + (record_links.empty? ? 0 : 1)
end
fields() click to toggle source
# File lib/presentation/grid.rb, line 34
def fields
  @fields ||= Presenting::FieldSet.new(Field, :name, :value)
end
fields=(args) click to toggle source

Paradigm Example:

Grid.new(:fields => [
  :email,
  {"Full Name" => proc{|r| [r.first_name, r.last_name].join(' ')}},
  {"Roles" => {:value => :roles, :type => :collection}}
])

Is equivalent to:

g = Grid.new
g.fields << :email
g.fields << {"Full Name" => proc{|r| [r.first_name, r.last_name].join(' ')},
g.fields << {"Roles" => {:value => :roles, :type => :collection}}
# File lib/presentation/grid.rb, line 28
def fields=(args)
  args.each do |field|
    self.fields << field
  end
end
iname() click to toggle source
# File lib/presentation/grid.rb, line 42
def iname; :grid end
paginate?() click to toggle source
# File lib/presentation/grid.rb, line 158
def paginate?
  defined? WillPaginate and (presentable.is_a? WillPaginate::Collection or presentable.respond_to?(:total_entries))
end
title() click to toggle source
# File lib/presentation/grid.rb, line 12
def title
  @title ||= self.id.titleize
end