Class: DisplayFor::Builder::CollectionBase

Inherits:
Base
  • Object
show all
Defined in:
lib/display_for/builder/collection_base.rb

Direct Known Subclasses

Csv, List, Table

Instance Attribute Summary collapse

Attributes inherited from Base

#html_options, #namespace, #resource_class, #template

Instance Method Summary collapse

Methods inherited from Base

#action, #attribute, #html

Constructor Details

#initialize(resource_class, collection, html_options, template, &block) ⇒ CollectionBase

Returns a new instance of CollectionBase.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/display_for/builder/collection_base.rb', line 6

def initialize(resource_class, collection, html_options, template, &block)
  @collection = collection

  if resource_class.is_a?(Array)
    @namespace = resource_class
    @resource_class = @namespace.pop
  else
    @namespace = []
    @resource_class = resource_class
  end

  super(html_options, template, &block)
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



4
5
6
# File 'lib/display_for/builder/collection_base.rb', line 4

def collection
  @collection
end

Instance Method Details

#default_actionsObject



20
21
22
23
24
# File 'lib/display_for/builder/collection_base.rb', line 20

def default_actions
  action :show
  action :edit, :link_to => lambda { |r| [:edit] + @namespace + [r] }
  action :delete, :method => :delete, :confirm => "Are you sure?"
end