Class: ViewModels::Helpers::Mapping::Collection
- Inherits:
-
Object
- Object
- ViewModels::Helpers::Mapping::Collection
- Defined in:
- lib/view_models/helpers/collection.rb
Overview
The Collection view_model helper has the purpose of presenting presentable collections.
-
Render as list
-
Render as table
-
Render as collection
-
Render a pagination
Instance Method Summary (collapse)
-
- (Object) collection(options = {})
Renders a collection.
-
- (Collection) initialize(collection, context)
constructor
A new instance of Collection.
-
- (Object) list(options = {})
Renders a list (in the broadest sense of the word).
-
- (Object) pagination(options = {})
Renders a pagination.
-
- (Object) table(options = {})
Renders a table.
Constructor Details
- (Collection) initialize(collection, context)
A new instance of Collection
37 38 39 |
# File 'lib/view_models/helpers/collection.rb', line 37 def initialize collection, context @collection, @context = collection, context end |
Instance Method Details
- (Object) collection(options = {})
Note:
The only difference between a list and a collection is the enclosing list type. While list uses ol, the collection uses ul.
Renders a collection.
63 64 65 |
# File 'lib/view_models/helpers/collection.rb', line 63 def collection = {} render_partial :collection, template_locals(:collection_item, ) end |
- (Object) list(options = {})
Renders a list (in the broadest sense of the word).
49 50 51 |
# File 'lib/view_models/helpers/collection.rb', line 49 def list = {} render_partial :list, template_locals(:list_item, ) end |
- (Object) pagination(options = {})
Renders a pagination.
89 90 91 |
# File 'lib/view_models/helpers/collection.rb', line 89 def pagination = {} render_partial :pagination, template_locals(:pagination, {:separator => '|'}.merge()) end |
- (Object) table(options = {})
Renders a table.
Note: Each item represents a table row.
77 78 79 |
# File 'lib/view_models/helpers/collection.rb', line 77 def table = {} render_partial :table, template_locals(:table_row, ) end |