Class: RubyMVC::Models::TableModel

Inherits:
Model
  • Object
show all
Defined in:
lib/ruby_mvc/models/table_model.rb

Overview

The TableModel class expands the concepts of the Model class to a number of related rows with the same properties defined for the model.

Instance Method Summary collapse

Methods inherited from Model

#[]=, adapt, #each_label, #initialize, #is_editable?, #keys, #label_for, #labels, #link_labels, #size

Methods included from Toolkit::SignalHandler::ClassMethods

#signal, #signals, #valid_signal!, #valid_signal?

Methods included from Toolkit::SignalHandler

#signal_connect, #signal_disconnect, #signal_emit

Constructor Details

This class inherits a constructor from RubyMVC::Models::Model

Instance Method Details

#[](idx) ⇒ Object

This method is used to retrieve the model instance for the given row index



134
135
# File 'lib/ruby_mvc/models/table_model.rb', line 134

def [](idx)
end

#create_rows(count = 1) ⇒ Object

This method is used to create a number of row data elements that will be inserted into the model at the specified location using the #insert_row or #insert_rows method.

The result is an array of row data instances in whatever format is deemed suitable for the model instance to create.



63
64
# File 'lib/ruby_mvc/models/table_model.rb', line 63

def create_rows(count = 1)
end

#each(&block) ⇒ Object

This method will iterate over each of the rows and provide the caller with a reference to the row instance, which is also conformant with the Model API



114
115
# File 'lib/ruby_mvc/models/table_model.rb', line 114

def each(&block)
end

#each_with_index(&block) ⇒ Object

This method will iterate over each of rows and provide the caller with a reference to the row instance as a model and the index of the row.



121
122
# File 'lib/ruby_mvc/models/table_model.rb', line 121

def each_with_index(&block)
end

#insert_row(index, row) ⇒ Object

This method is used to insert a single row into the model at the given row index.



69
70
71
# File 'lib/ruby_mvc/models/table_model.rb', line 69

def insert_row(index, row)
  signal_emit("rows-inserted", self, index, [ row ])
end

#insert_rows(index, rows) ⇒ Object

This method is used to insert an array of row objects into the model at the specified index



76
77
78
# File 'lib/ruby_mvc/models/table_model.rb', line 76

def insert_rows(index, rows)
  signal_emit("rows-inserted", self, index, rows)
end

#remove_row(index) ⇒ Object

This method is used remove a single row from the model and return a reference to the row model removed to the caller.

Note, the derived classes are responsible for emitting the appropriate signal since the data access is opaque to the base class.



88
89
# File 'lib/ruby_mvc/models/table_model.rb', line 88

def remove_row(index)
end

#remove_rows(index, count) ⇒ Object

This method is used remove multiple rows from the model and return a reference to the row models removed to the caller.

Note, the derived classes are responsible for emitting the appropriate signal since the data access is opaque to the base class.



99
100
# File 'lib/ruby_mvc/models/table_model.rb', line 99

def remove_rows(index, count)
end

#update_row(index, row) ⇒ Object

This method is used to update the specified row in the model and ensure that the appropriate notifications for all linked views are sent.



106
107
108
# File 'lib/ruby_mvc/models/table_model.rb', line 106

def update_row(index, row)
  signal_emit("row-changed", index, row)
end

#value_for(row, key) ⇒ Object

This method allows direct access into the model rows, in row-major order for the specified, zero-based index and property key



128
129
# File 'lib/ruby_mvc/models/table_model.rb', line 128

def value_for(row, key)
end