Class: RubyMVC::Models::ActiveRecordRowModel

Inherits:
Model
  • Object
show all
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

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, options = {})
  options[:data] = row
  super(options)
end

Instance Method Details

#entity_typeObject



38
39
40
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 38

def entity_type
  @data.class
end

#keysObject



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

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

#sizeObject



56
57
58
# File 'lib/ruby_mvc/models/ar_row_model.rb', line 56

def size
  @data.attributes.keys.size
end