qui-common-helpers 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/qui-common-helpers.rb +11 -2
- metadata +4 -4
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gemspec.email = "marcin@saepia.net"
|
10
10
|
gemspec.homepage = "http://q.saepia.net"
|
11
11
|
gemspec.authors = ["Marcin Lewandowski"]
|
12
|
-
gemspec.version = "0.0.
|
12
|
+
gemspec.version = "0.0.8"
|
13
13
|
gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "lib/*" ]
|
14
14
|
end
|
15
15
|
rescue LoadError
|
data/lib/qui-common-helpers.rb
CHANGED
@@ -65,10 +65,19 @@ module QUI
|
|
65
65
|
I18n.t(:"activerecord.enums.#{self.to_s.tableize.singularize}.#{attribute_name}.#{value}")
|
66
66
|
end
|
67
67
|
|
68
|
-
def validates_enum_of(attribute_name)
|
68
|
+
def validates_enum_of(attribute_name, options = {})
|
69
|
+
options.symbolize_keys!
|
70
|
+
|
71
|
+
|
69
72
|
@enums ||= []
|
70
73
|
@enums << attribute_name.to_sym
|
71
|
-
|
74
|
+
|
75
|
+
validation_options = { :in => I18n.t("activerecord.enums.#{table_name.singularize}.#{attribute_name}").collect{|k,v| k.to_s.to_i } }
|
76
|
+
[ :allow_nil, :allow_blank, :if, :message, :unless ].each do |option|
|
77
|
+
validation_options[option] = options[option] if options.has_key? option
|
78
|
+
end
|
79
|
+
|
80
|
+
validates_inclusion_of attribute_name, validation_options
|
72
81
|
end
|
73
82
|
|
74
83
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qui-common-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcin Lewandowski
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-20 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|