Class: Terrazzo::Page::Collection

Inherits:
Base
  • Object
show all
Defined in:
lib/terrazzo/page/collection.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#dashboard, #resource_class

Instance Method Summary collapse

Constructor Details

#initialize(dashboard, resource_class, order: Order.new) ⇒ Collection

Returns a new instance of Collection.



6
7
8
9
# File 'lib/terrazzo/page/collection.rb', line 6

def initialize(dashboard, resource_class, order: Order.new)
  super(dashboard, resource_class)
  @order = order
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'lib/terrazzo/page/collection.rb', line 4

def order
  @order
end

Instance Method Details

#attribute_namesObject



11
12
13
# File 'lib/terrazzo/page/collection.rb', line 11

def attribute_names
  dashboard.collection_attributes
end

#order_params_for(attr) ⇒ Object



19
20
21
# File 'lib/terrazzo/page/collection.rb', line 19

def order_params_for(attr)
  order.order_params_for(attr)
end

#ordered_by?(attr) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/terrazzo/page/collection.rb', line 15

def ordered_by?(attr)
  order.ordered_by?(attr)
end

#sort_direction_for(attr) ⇒ Object



23
24
25
# File 'lib/terrazzo/page/collection.rb', line 23

def sort_direction_for(attr)
  order.ordered_by?(attr) ? order.direction.to_s : nil
end