human_error 3.1.0 → 3.2.0
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0485dc051370d7d8e00e3feca926bcd40a82a6ed
|
4
|
+
data.tar.gz: aef69da530be7354df87196165d9fea30bb99e4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd94fd5cc7445252aa55f92d5b28e7733ba04c82460600de37c52d9f78d43a0fd94d04bc9575f30151eb562c4d15617e993c70f78a906a100b0ea153582deeaa
|
7
|
+
data.tar.gz: 9006725793427ee7dcc66bf582c6cf7615e344f748f1e1baf3f0ef6c632b9a313e9d9e7cd9b5cd05c1838853e10292eaa21875b91f04bd6da126d72b0941d746
|
@@ -1,23 +1,9 @@
|
|
1
|
+
require 'human_error/resource_naming'
|
2
|
+
|
1
3
|
class HumanError
|
2
4
|
module RescuableResource
|
3
|
-
module ClassMethods
|
4
|
-
def plural_resource_name
|
5
|
-
name[/(\w+)Controller\z/, 1].
|
6
|
-
underscore.
|
7
|
-
pluralize.
|
8
|
-
downcase
|
9
|
-
end
|
10
|
-
|
11
|
-
def singular_resource_name
|
12
|
-
name[/(\w+)Controller\z/, 1].
|
13
|
-
underscore.
|
14
|
-
singularize.
|
15
|
-
downcase
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
5
|
def self.included(base)
|
20
|
-
base.
|
6
|
+
base.include ResourceNaming
|
21
7
|
|
22
8
|
base.rescue_from 'ActiveRecord::RecordInvalid',
|
23
9
|
'ActiveRecord::RecordNotSaved',
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class HumanError
|
2
|
+
module ResourceNaming
|
3
|
+
CONTROLLER_RESOURCE_NAME_PATTERN = /\A((.*?::)?.*?)(\w+)Controller\z/
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def plural_resource_name
|
7
|
+
@plural_resource_name ||= name[CONTROLLER_RESOURCE_NAME_PATTERN, 3].
|
8
|
+
underscore.
|
9
|
+
pluralize.
|
10
|
+
downcase
|
11
|
+
end
|
12
|
+
|
13
|
+
def singular_resource_name
|
14
|
+
@singular_resource_name ||= name[CONTROLLER_RESOURCE_NAME_PATTERN, 3].
|
15
|
+
underscore.
|
16
|
+
singularize.
|
17
|
+
downcase
|
18
|
+
end
|
19
|
+
|
20
|
+
def resource_class_name
|
21
|
+
@resource_class_name ||= singular_resource_name.
|
22
|
+
camelize
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.included(base)
|
27
|
+
base.extend ClassMethods
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,23 +1,9 @@
|
|
1
|
-
|
2
|
-
module VerifiableResource
|
3
|
-
module ClassMethods
|
4
|
-
def plural_resource_name
|
5
|
-
name[/(\w+)Controller\z/, 1].
|
6
|
-
underscore.
|
7
|
-
pluralize.
|
8
|
-
downcase
|
9
|
-
end
|
10
|
-
|
11
|
-
def singular_resource_name
|
12
|
-
name[/(\w+)Controller\z/, 1].
|
13
|
-
underscore.
|
14
|
-
singularize.
|
15
|
-
downcase
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require 'human_error/resource_naming'
|
18
2
|
|
3
|
+
class HumanError
|
4
|
+
module ResourceNaming
|
19
5
|
def self.included(base)
|
20
|
-
base.
|
6
|
+
base.include ResourceNaming
|
21
7
|
|
22
8
|
base.before_action except: %i{index create} do
|
23
9
|
model = public_send(self.class.singular_resource_name)
|
data/lib/human_error/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jfelchner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/human_error/errors/request_errors/parameter_missing_error.rb
|
92
92
|
- lib/human_error/errors/request_errors/unpermitted_parameters_error.rb
|
93
93
|
- lib/human_error/rescuable_resource.rb
|
94
|
+
- lib/human_error/resource_naming.rb
|
94
95
|
- lib/human_error/utilities/string.rb
|
95
96
|
- lib/human_error/verifiable_resource.rb
|
96
97
|
- lib/human_error/version.rb
|