Class: RubyMVC::Models::ActiveRecordRowModel
- Defined in:
- lib/ruby_mvc/models/ar_row_model.rb
Overview
This class provides a Model adapter implementation for ActiveRecordBase class instances.
Instance Method Summary collapse
- #entity_type ⇒ Object
-
#initialize(row, options = {}) ⇒ ActiveRecordRowModel
constructor
A new instance of ActiveRecordRowModel.
- #keys ⇒ Object
-
#link_labels ⇒ Object
This method provides information about inter-model links to provide built-in support for master-detail types of relationships between models.
- #size ⇒ Object
Methods inherited from Model
#[], #[]=, adapt, #each_label, #is_editable?, #label_for, #labels
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
#initialize(row, options = {}) ⇒ ActiveRecordRowModel
Returns a new instance of ActiveRecordRowModel.
33 34 35 36 |
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 33 def initialize(row, = {}) [:data] = row super() end |
Instance Method Details
#entity_type ⇒ Object
38 39 40 |
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 38 def entity_type @data.class end |
#keys ⇒ Object
42 43 44 |
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 42 def keys @data.attributes.keys.collect { |k| k.to_sym } end |
#link_labels ⇒ Object
This method provides information about inter-model links to provide built-in support for master-detail types of relationships between models.
50 51 52 53 54 |
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 50 def link_labels # FIXME: should probably implement this intelligently to # do some introspection magic {} end |
#size ⇒ Object
56 57 58 |
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 56 def size @data.attributes.keys.size end |