class ContactManager::ContactManagerPresenter
Attributes
results[RW]
Public Class Methods
new(contact_repository = nil)
click to toggle source
# File lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_manager_presenter.rb, line 9 def initialize(contact_repository = nil) @contact_repository = contact_repository || ContactRepository.new @results = [] end
Public Instance Methods
find()
click to toggle source
# File lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_manager_presenter.rb, line 18 def find filter_map = {} @@contact_attributes.each do |attribute_name| filter_map[attribute_name] = self.send(attribute_name) if self.send(attribute_name) end self.results = @contact_repository.find(filter_map) @sort_attribute_name = nil @sort_direction_ascending = nil end
list()
click to toggle source
# File lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_manager_presenter.rb, line 14 def list self.results = @contact_repository.find({}) end
toggle_sort(attribute_name)
click to toggle source
# File lib/glimmer-dsl-opal/samples/elaborate/contact_manager/contact_manager_presenter.rb, line 28 def toggle_sort(attribute_name) @sort_attribute_name = attribute_name @sort_direction_ascending = !@sort_direction_ascending sorted_results = self.results.sort_by {|contact| contact.send(attribute_name).downcase} sorted_results = sorted_results.reverse unless @sort_direction_ascending self.results = sorted_results end