Class: AppKit::Views::Table
- Inherits:
-
Object
- Object
- AppKit::Views::Table
- Defined in:
- lib/app_kit/views/table.rb
Instance Attribute Summary collapse
-
#filter_enabled ⇒ Object
Returns the value of attribute filter_enabled.
-
#page ⇒ Object
Returns the value of attribute page.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#resource_scope ⇒ Object
Returns the value of attribute resource_scope.
- #title ⇒ Object
Instance Method Summary collapse
- #icon ⇒ Object
-
#initialize(resource, options = {}) ⇒ Table
constructor
A new instance of Table.
- #records ⇒ Object
Constructor Details
#initialize(resource, options = {}) ⇒ Table
Returns a new instance of Table.
5 6 7 8 9 10 11 12 13 |
# File 'lib/app_kit/views/table.rb', line 5 def initialize(resource, = {}) resource = AppKit::Resource.find(resource) if resource.is_a? Symbol @resource = resource @resource_scope = [:resource_scope] @title = [:title] @records = [:records] @page = [:page] || 1 @filter_enabled = ([:filter].nil? ? true : false) end |
Instance Attribute Details
#filter_enabled ⇒ Object
Returns the value of attribute filter_enabled.
2 3 4 |
# File 'lib/app_kit/views/table.rb', line 2 def filter_enabled @filter_enabled end |
#page ⇒ Object
Returns the value of attribute page.
2 3 4 |
# File 'lib/app_kit/views/table.rb', line 2 def page @page end |
#resource ⇒ Object
Returns the value of attribute resource.
2 3 4 |
# File 'lib/app_kit/views/table.rb', line 2 def resource @resource end |
#resource_scope ⇒ Object
Returns the value of attribute resource_scope.
2 3 4 |
# File 'lib/app_kit/views/table.rb', line 2 def resource_scope @resource_scope end |
#title ⇒ Object
19 20 21 |
# File 'lib/app_kit/views/table.rb', line 19 def title @title || resource.plural_display_name end |
Instance Method Details
#icon ⇒ Object
15 16 17 |
# File 'lib/app_kit/views/table.rb', line 15 def icon resource. || 'list' end |
#records ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/app_kit/views/table.rb', line 23 def records unless @records @records = @resource.model @records = @records.send(resource_scope) if resource_scope @records.page(page) end @records.page(page) end |