Class: UiBibz::Ui::Ux::Tables::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/ui_bibz/ui/ux/tables/components/store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store) ⇒ Store

Store Use WillPaginate store methods



11
12
13
14
15
16
17
18
# File 'lib/ui_bibz/ui/ux/tables/components/store.rb', line 11

def initialize(store)
  raise 'Store is nil!' if store.nil?
  raise 'Store can be created only with "table_search_pagination" method!' if store.try(:records).nil?

  @records = store.records
  @store   = store
  @model   = store.model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



8
9
10
# File 'lib/ui_bibz/ui/ux/tables/components/store.rb', line 8

def model
  @model
end

#recordsObject

Returns the value of attribute records.



7
8
9
# File 'lib/ui_bibz/ui/ux/tables/components/store.rb', line 7

def records
  @records
end

Instance Method Details

#columnsObject



24
25
26
27
28
# File 'lib/ui_bibz/ui/ux/tables/components/store.rb', line 24

def columns
  @columns ||= Columns.new(model.attribute_names.map do |attribute_name|
    Column.new(attribute_name, { name: attribute_name.humanize })
  end)
end

#parametersObject



34
35
36
# File 'lib/ui_bibz/ui/ux/tables/components/store.rb', line 34

def parameters
  @store.params.to_h
end

#paramsObject



30
31
32
# File 'lib/ui_bibz/ui/ux/tables/components/store.rb', line 30

def params
  @store.params || {}
end