Class: InformantCommon::Model::ActiveModel

Inherits:
Base
  • Object
show all
Defined in:
lib/informant-common/model/active_model.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #id, #name

Instance Method Summary collapse

Methods inherited from Base

#add_error, #as_json, #to_json

Constructor Details

#initialize(active_model) ⇒ ActiveModel

Returns a new instance of ActiveModel.



4
5
6
7
8
9
10
11
# File 'lib/informant-common/model/active_model.rb', line 4

def initialize(active_model)
  self.id = active_model.object_id
  self.name = active_model.class.name
  self.errors = []
  active_model.errors.each do |field, error|
    add_error(field.to_s, extract_value(active_model, field), error)
  end
end