sequel_sexy_validations 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -9,8 +9,30 @@ module Sequel
9
9
 
10
10
  return unless model.changed_columns.include?(attribute)
11
11
 
12
- unless model.class.filter(~:id => model.id, attribute => value).empty?
13
- model.errors.add(attribute, "bereits vergeben")
12
+ unless options.is_a?(Hash)
13
+ options = {
14
+ :scope => options,
15
+ }
16
+ end
17
+
18
+ options[:message] ||= "bereits vergeben"
19
+
20
+ dataset = model.class.filter(~:id => model.id, attribute => value)
21
+ if options[:scope].is_a?(Array)
22
+ options[:scope].each do |v|
23
+ case v
24
+ when Symbol
25
+ dataset = dataset.filter(v => model.send(v))
26
+ when Proc
27
+ dataset = dataset.filter(v.call(model))
28
+ else
29
+ dataset = dataset.filter(v)
30
+ end
31
+ end
32
+ end
33
+
34
+ unless dataset.empty?
35
+ model.errors.add(attribute, options[:message])
14
36
  end
15
37
  end
16
38
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sequel_sexy_validations}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Corin Langosch"]
12
- s.date = %q{2010-09-17}
12
+ s.date = %q{2010-09-28}
13
13
  s.description = %q{Sequel plugin which provides sexy validations for model.}
14
14
  s.email = %q{info@netskin.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Corin Langosch
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-17 00:00:00 +01:00
17
+ date: 2010-09-28 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency