Class: HelloFormMvpPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer-dsl-web/samples/hello/hello_form_mvp/presenters/hello_form_mvp_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHelloFormMvpPresenter

Returns a new instance of HelloFormMvpPresenter.



6
7
8
# File 'lib/glimmer-dsl-web/samples/hello/hello_form_mvp/presenters/hello_form_mvp_presenter.rb', line 6

def initialize
  @contacts = fetch_contacts
end

Instance Attribute Details

#contactsObject

Returns the value of attribute contacts.



4
5
6
# File 'lib/glimmer-dsl-web/samples/hello/hello_form_mvp/presenters/hello_form_mvp_presenter.rb', line 4

def contacts
  @contacts
end

Instance Method Details

#add_contactObject



21
22
23
24
# File 'lib/glimmer-dsl-web/samples/hello/hello_form_mvp/presenters/hello_form_mvp_presenter.rb', line 21

def add_contact
  contacts << Contact.new(name: new_contact.name, email: new_contact.email)
  new_contact.name = new_contact.email = ''
end

#fetch_contactsObject



10
11
12
13
14
15
# File 'lib/glimmer-dsl-web/samples/hello/hello_form_mvp/presenters/hello_form_mvp_presenter.rb', line 10

def fetch_contacts
  [
    Contact.new(name: 'John Doe', email: '[email protected]'),
    Contact.new(name: 'Jane Doe', email: '[email protected]'),
  ]
end

#new_contactObject



17
18
19
# File 'lib/glimmer-dsl-web/samples/hello/hello_form_mvp/presenters/hello_form_mvp_presenter.rb', line 17

def new_contact
  @new_contact ||= Contact.new
end