Class: ListPresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeListPresenter

Returns a new instance of ListPresenter.



6
7
8
9
# File 'lib/glimmer-dsl-web/samples/hello/hello_mutation_content_data_binding.rb', line 6

def initialize
  @list = []
  @new_list_item = ''
end

Instance Attribute Details

#listObject

Returns the value of attribute list.



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

def list
  @list
end

#new_list_itemObject

Returns the value of attribute new_list_item.



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

def new_list_item
  @new_list_item
end

Instance Method Details

#append_list_itemObject



11
12
13
14
# File 'lib/glimmer-dsl-web/samples/hello/hello_mutation_content_data_binding.rb', line 11

def append_list_item
  list.push(new_list_item)
  clear_new_list_item
end

#clear_new_list_itemObject



21
22
23
# File 'lib/glimmer-dsl-web/samples/hello/hello_mutation_content_data_binding.rb', line 21

def clear_new_list_item
  self.new_list_item = ''
end

#entering_new_list_item?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/glimmer-dsl-web/samples/hello/hello_mutation_content_data_binding.rb', line 25

def entering_new_list_item?
  new_list_item.empty?
end

#prepend_list_itemObject



16
17
18
19
# File 'lib/glimmer-dsl-web/samples/hello/hello_mutation_content_data_binding.rb', line 16

def prepend_list_item
  list.prepend(new_list_item)
  clear_new_list_item
end