silent_fail_check 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/silent_fail_check.rb +47 -0
  3. metadata +72 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTRjZjEyZjg0ZjUwYTY2NjMxNWQ0YmI1ODYyMDA4N2IzODkzODc2Ng==
5
+ data.tar.gz: !binary |-
6
+ YjJiZTZmY2I2Y2RiNDhhMWNmMmRhZjBmYmVmYjVmMTRkYjFiMmFlNg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTcyODdiMGY4NmZhODU5NDIzMWY2OWM5MWUxOGI0YmRkMjE1NTI3YjYwOTI1
10
+ ZTIyZTg3NDk2MmJkODkwMWVjODcyMDE5YmE5MWQwZDFhM2IzZGJmODdmY2Q4
11
+ MzdjNWQ4NjYxYjMxNTBhODBkNTNmN2ViMjVkZDI0ZjQ2YjM2Y2Y=
12
+ data.tar.gz: !binary |-
13
+ MjYzZTE2ZTM1Y2EyNTllODZlY2RhYWZjNDQwMmM4NDU1YWYwNWNiMTFjYjUz
14
+ MmZlZTIwNmQ2ZmYxNjA0NjJhMGMyZjQ1ZmU0M2I5NzVjNjM2MjIxMmRiZGQ1
15
+ NDEzZWFiYWM5ZDNkMDk2YmJkZWYyNjlhYmU0ZjFiYjU0ZDRkMzc=
@@ -0,0 +1,47 @@
1
+ require 'active_record'
2
+
3
+ module SilentFailCheck
4
+ CheckParameters = Struct.new(:sym, :args, :block)
5
+
6
+ def silent_fail_check sym, *args, &block
7
+ extend ClassMethods
8
+ include InstanceMethods
9
+
10
+ @check_parameters = CheckParameters.new(sym, args, block)
11
+
12
+ method_name = "add_#{sym}_fail_check"
13
+ send(method_name) if respond_to?(method_name, true)
14
+ end
15
+
16
+ module ClassMethods
17
+
18
+ private
19
+
20
+ def check_parameters
21
+ @check_parameters
22
+ end
23
+
24
+ def add_validation_fail_check
25
+ after_validation "#{check_parameters.sym}_fail_check"
26
+ end
27
+ end
28
+
29
+ module InstanceMethods
30
+
31
+ private
32
+
33
+ def validation_fail_check
34
+ p = self.class.send(:check_parameters)
35
+
36
+ if p.block.nil?
37
+ p.args.each do |a|
38
+ puts "#{self.class} : #{a} #{self.errors[a]}" if self.errors[a].present?
39
+ end
40
+ else
41
+ p.args.collect &p.block
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ ActiveRecord::Base.extend SilentFailCheck
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: silent_fail_check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adrien Folie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ description: Handle silent failure on ActiveRecord::Base
42
+ email: folie.adrien@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/silent_fail_check.rb
48
+ homepage: http://rubygems.org/gems/silent_fail_check
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.2.2
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: silent_fail_check
72
+ test_files: []