Module: DataMapper::ActiveModel::InstanceMethods

Defined in:
lib/dm-active_model.rb

Instance Method Summary collapse

Instance Method Details

#errorsObject



38
39
40
41
42
43
# File 'lib/dm-active_model.rb', line 38

def errors
  obj = Object.new
  def obj.[](key)         [] end
  def obj.full_messages() [] end
  obj
end

#persisted?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/dm-active_model.rb', line 12

def persisted?
  saved?
end

#to_keyObject



16
17
18
# File 'lib/dm-active_model.rb', line 16

def to_key
  key
end

#to_modelObject



8
9
10
# File 'lib/dm-active_model.rb', line 8

def to_model
  self
end

#to_paramObject



20
21
22
23
24
25
26
27
# File 'lib/dm-active_model.rb', line 20

def to_param
  return nil if key.nil?
  if key.length > 1
    raise "You need to implement #to_param yourself to support this key: #{self.class.key.inspect}"
  else
    self.key.first.to_s
  end
end

#valid?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/dm-active_model.rb', line 34

def valid?
  true
end