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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d16063fe2662ff4a43581cc87c02efe576a98428
4
- data.tar.gz: 29fa47737e74195575d317001d38492dce5f9758
3
+ metadata.gz: 9fda1906bf0c168e1a72533db653484e1a090cac
4
+ data.tar.gz: 9d0316eb0a4991b5946987ba2aef0849332a8108
5
5
  SHA512:
6
- metadata.gz: 3bb48c3e39c921fa91a47847090917494c1b590eea14d32ae1c50be4ca003a4f61aa2dbdea91b8fd2a888be10b0113be7cd58230002265c34d6932f820817e4d
7
- data.tar.gz: 5ab6e603cdff353a07009f7fcb526282ca300885d06f664ad98c798e9a2db00b4f6a08b585629ba9da996536591686263e58a2aaa54d5c29a4029be0c8e91194
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("RegisterMethods")
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
@@ -1,7 +1,7 @@
1
1
  module ActiveEvent
2
2
  # Returns the version of the currently loaded ActiveEvent as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new '0.5.0.pre'
4
+ Gem::Version.new '0.5.0.pre2'
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
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.pre
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-10 00:00:00.000000000 Z
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord