Module: DataMapper::ActiveModel::InstanceMethods

Defined in:
lib/dm-active_model.rb

Instance Method Summary collapse

Instance Method Details

#errorsObject



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

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

#persisted?Boolean

Returns:

  • (Boolean)


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

def persisted?
  saved?
end

#to_keyObject



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

def to_key
  key
end

#to_modelObject



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

def to_model
  self
end

#to_paramObject



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

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)


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

def valid?
  true
end