human_error 3.1.0 → 3.2.0

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: 8bcd73a9e09835dff5279ebae166f1b379ff3b26
4
- data.tar.gz: ce33687c79d3c4a7b00e14603bbccd77dad48feb
3
+ metadata.gz: 0485dc051370d7d8e00e3feca926bcd40a82a6ed
4
+ data.tar.gz: aef69da530be7354df87196165d9fea30bb99e4f
5
5
  SHA512:
6
- metadata.gz: 4c2de3573c9de4666ea9810dc849a76924fc7ec592f2615fbc9904bf7a7f0ed3dfc5f035a363f32c92a1751e83aa7d1189432cb45ecb84cb4864d648690630c9
7
- data.tar.gz: f373af39d2dfe44009ed2a3901cf66aaefe0ea48898f6bc74c032dc3f04294bd123b3ac3073d261007ad01f6852a6a53a84319a9118fed3d656ec5d50ccb9f8e
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.extend ClassMethods
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
- class HumanError
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.extend ClassMethods
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)
@@ -1,3 +1,3 @@
1
1
  class HumanError
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
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.1.0
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-29 00:00:00.000000000 Z
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