Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'will_paginate/array'
- module Documents
- class IndexPresenter < Documents::BasePresenter
- def initialize(controller, client, direction = :incoming)
- @controller = controller
- @client = client
- @direction = direction
- end
- def title
- @title ||= outgoing? ? 'Nosūtītās vēstules' : 'Saņemtās vēstules'
- end
- def date_title
- @date_title ||= outgoing? ? 'Nosūtīšanas datums' : 'Saņemšanas datums'
- end
- def documents
- # @documents = Enumerator.new do |yielder|
- documents ||= outgoing? ? @client.documents.outgoing : @client.documents.incoming
- documents = documents.map do |document|
- Index::DocumentPresenter.new(@controller, @client, document) unless document.empty_block_correnction?
- end.compact
- # end
- documents = documents.paginate(per_page: 1, page: @controller.params[:page])
- end
- def outgoing?
- @direction == :outgoing
- end
- def incoming?
- @direction == :incoming
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement