Class: InformantRails::Model

Inherits:
Struct
  • Object
show all
Defined in:
lib/informant-rails/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



2
3
4
# File 'lib/informant-rails/model.rb', line 2

def model
  @model
end

Instance Method Details

#as_json(*args) ⇒ Object



13
14
15
# File 'lib/informant-rails/model.rb', line 13

def as_json(*args)
  { name: name, errors: errors.map(&:as_json) }
end

#errorsObject



7
8
9
10
11
# File 'lib/informant-rails/model.rb', line 7

def errors
  model.errors.map do |field, error|
    InformantRails::FieldError.new(field.to_s, model[field], error)
  end
end

#nameObject



3
4
5
# File 'lib/informant-rails/model.rb', line 3

def name
  model.class.name
end