crankharder-friendlyErrorMessages 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/friendlyErrorMessages.gemspec +2 -2
- data/lib/friendlyErrorMessages.rb +7 -22
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{friendlyErrorMessages}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Josh Sharpe"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-08}
|
13
13
|
s.description = %q{fun}
|
14
14
|
s.email = %q{josh.m.sharpe@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -1,20 +1,9 @@
|
|
1
|
+
# User.read_inheritable_attribute(:reflections).keys
|
2
|
+
# u.send(:profile).try(:loaded?)
|
3
|
+
|
1
4
|
module ActiveRecord
|
2
5
|
class Errors
|
3
|
-
def friendly_messages(
|
4
|
-
messages = []
|
5
|
-
includes = [options[:include]].compact
|
6
|
-
|
7
|
-
includes.each do |assoc|
|
8
|
-
if assoc.is_a?(Symbol)
|
9
|
-
messages += @base.send(assoc).errors.friendly_messages
|
10
|
-
elsif assoc.kind_of?(Hash)
|
11
|
-
assoc.each do |key, value|
|
12
|
-
messages += @base.send(key).errors.friendly_messages
|
13
|
-
messages += @base.send(key).errors.friendly_messages(:include => value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
messages +=
|
6
|
+
def friendly_messages()
|
18
7
|
if @base.class.friendly_excluded_attributes.blank?
|
19
8
|
full_messages
|
20
9
|
else
|
@@ -23,18 +12,14 @@ module ActiveRecord
|
|
23
12
|
end.map do |e|
|
24
13
|
e.full_message
|
25
14
|
end
|
26
|
-
end
|
27
|
-
messages.flatten.sort
|
15
|
+
end.flatten
|
28
16
|
end
|
29
17
|
end
|
30
18
|
|
31
19
|
class Base
|
32
20
|
def self.exclude_unfriendly_attributes(*args)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def self.friendly_excluded_attributes
|
37
|
-
@friendly_excluded_attributes
|
21
|
+
attr_accessor :friendly_excluded_attributes
|
22
|
+
friendly_excluded_attributes = args
|
38
23
|
end
|
39
24
|
end
|
40
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crankharder-friendlyErrorMessages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Sharpe
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-08 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|