active_event 0.5.0.pre → 0.5.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_event/validations.rb +53 -2
- data/lib/active_event/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fda1906bf0c168e1a72533db653484e1a090cac
|
4
|
+
data.tar.gz: 9d0316eb0a4991b5946987ba2aef0849332a8108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 159a18fd05d157683d785797a76fd0ff2cd2c766b026966f8ce405012baf709a2bf4d2e3a680ef9b811a82509456400d57d3b18cceb18faad9e27b63d8314496
|
7
|
+
data.tar.gz: 4aa11e82f5f5137273a7c0138f12fc4418286eb61a4642935d165aeaf0544f5366dc08297a69e953ba30d44656375751f9392a49b04f86ef899cb76f74e1bd2a
|
@@ -5,13 +5,64 @@ module ActiveEvent
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
7
|
super
|
8
|
-
base.extend const_get(
|
8
|
+
base.extend const_get('RegisterMethods')
|
9
9
|
end
|
10
10
|
|
11
11
|
module RegisterMethods
|
12
|
+
def skip_validate(*args)
|
13
|
+
options = args.extract_options!
|
14
|
+
if options.key?(:on)
|
15
|
+
options = options.dup
|
16
|
+
options[:if] = Array(options[:if])
|
17
|
+
options[:if].unshift("validation_context == :#{options[:on]}")
|
18
|
+
end
|
19
|
+
args << options
|
20
|
+
skip_callback(:validate, *args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def skip_validates(*attributes)
|
24
|
+
defaults = attributes.extract_options!.dup
|
25
|
+
validations = defaults.slice!(*_validates_default_keys)
|
26
|
+
|
27
|
+
return if attributes.empty?
|
28
|
+
return if validations.empty?
|
29
|
+
|
30
|
+
defaults[:attributes] = attributes
|
31
|
+
|
32
|
+
validations.each do |key, options|
|
33
|
+
next unless options
|
34
|
+
key = "#{key.to_s.camelize}Validator"
|
35
|
+
|
36
|
+
begin
|
37
|
+
validator = key.include?('::') ? key.constantize : const_get(key)
|
38
|
+
rescue NameError
|
39
|
+
raise ArgumentError, "Unknown validator: '#{key}'"
|
40
|
+
end
|
41
|
+
|
42
|
+
skip_validates_with(validator, defaults.merge(_parse_validates_options(options)))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def skip_validates_with(*args)
|
47
|
+
options = args.extract_options!
|
48
|
+
args.each do |klass|
|
49
|
+
validator = klass.new(options)
|
50
|
+
|
51
|
+
if validator.respond_to?(:attributes) && !validator.attributes.empty?
|
52
|
+
validator.attributes.each do |attribute|
|
53
|
+
_validators[attribute.to_sym].reject! { |x| x.instance_of? klass } if _validators.key? attribute.to_sym
|
54
|
+
end
|
55
|
+
else
|
56
|
+
_validators[nil].reject! { |x| x.instance_of? klass }
|
57
|
+
end
|
58
|
+
|
59
|
+
skip_validate(validator, options)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
12
63
|
def validation_target(target)
|
13
64
|
ValidationsRegistry.register self, target
|
14
65
|
end
|
15
66
|
end
|
16
67
|
end
|
17
|
-
end
|
68
|
+
end
|
data/lib/active_event/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.
|
4
|
+
version: 0.5.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Reischuck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|