errogant 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/errogant.rb +12 -13
  2. metadata +3 -3
@@ -1,22 +1,21 @@
1
1
  module Errogant
2
2
 
3
- VERSION = '0.0.1'
4
-
5
- @error_map = { }
6
-
7
- def pretty_errors(model)
8
- map_key = model.class.name
9
-
10
- if !error_map[map_key]
11
- return model.errors.full_messages.join('. ')
12
- end
3
+ VERSION = '0.0.2'
13
4
 
5
+ def included
6
+ cattr_accessor :error_map
14
7
  end
15
8
 
16
- def error_map(model_class = nil, model_hash = nil)
17
- if !model_class && !model_hash
18
- return @error_map
9
+ def pretty_errors
10
+ output = []
11
+ errors.keys.each do |error_key|
12
+ if !self.class.error_map[error_key]
13
+ output.push errors[error_key].full_message
14
+ else
15
+ output.push self.class.error_map[error_key]
16
+ end
19
17
  end
18
+ output
20
19
  end
21
20
 
22
21
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errogant
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zack Parker