Sha256: b1962d550add9e0838499351a684985cf6e1c4bf16a7aa12c6809d1f5fdec6f5

Contents?: true

Size: 748 Bytes

Versions: 6

Compression:

Stored size: 748 Bytes

Contents

require_relative "contact_repository"

class ContactManager
  class ContactManagerPresenter
    attr_accessor :results
    @@contact_attributes = [:first_name, :last_name, :email]
    @@contact_attributes.each {|attribute_name| attr_accessor attribute_name}
  
    def initialize(contact_repository = nil)
      @contact_repository = contact_repository || ContactRepository.new
      @results = []
    end
  
    def list
      self.results = @contact_repository.find({})
    end
  
    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)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
glimmer-dsl-swt-0.6.9 samples/elaborate/contact_manager/contact_manager_presenter.rb
glimmer-dsl-swt-0.6.8 samples/elaborate/contact_manager/contact_manager_presenter.rb
glimmer-dsl-swt-0.6.7 samples/elaborate/contact_manager/contact_manager_presenter.rb
glimmer-dsl-swt-0.6.6 samples/elaborate/contact_manager/contact_manager_presenter.rb
glimmer-dsl-swt-0.6.5 samples/elaborate/contact_manager/contact_manager_presenter.rb
glimmer-dsl-swt-0.6.4 samples/elaborate/contact_manager/contact_manager_presenter.rb