Module: DataMapper::ActiveModel::InstanceMethods

Includes:
ActiveModel::Conversion
Defined in:
lib/dm-active_model.rb

Instance Method Summary collapse

Instance Method Details

#errorsObject



44
45
46
47
48
49
# File 'lib/dm-active_model.rb', line 44

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

#persisted?Boolean

Returns:

  • (Boolean)


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

def persisted?
  saved?
end

#to_keyObject



22
23
24
# File 'lib/dm-active_model.rb', line 22

def to_key
  key
end

#to_modelObject



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

def to_model
  self
end

#to_paramObject



26
27
28
29
30
31
32
33
# File 'lib/dm-active_model.rb', line 26

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)


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

def valid?
  true
end