moromi-error 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: 832c6cfe1cf0f2b4b4bf3986da115b1131a81fd3beedec14d282c0f29dfe8540
4
- data.tar.gz: 0e1ced5d0279108a6e504087b836ee1591914eee2d812091a4e192fb83d00256
3
+ metadata.gz: 7b587a5b916270e9fc2f606b34cd1a1079935b3b767ad268c3c912a2ad7c11e7
4
+ data.tar.gz: 598fa10b9299e177b7853d87a4ee73c11a6afe6ad122eb737de3ee75aa1a6408
5
5
  SHA512:
6
- metadata.gz: 876be6091b110ac574c7e8757ce37f8da74d73419b07bd1e292511cea14bbc42cc4971299382b0dee9f611e9b01eca5fe08210f9f1a2153ad8fca2f64cb19130
7
- data.tar.gz: f465b512ed31e6fa28a3714a1f21cf8c1ccacbf5e6202fb837c3382fc75460d5035fe3228e04348aff582e204eb658eb3cf72349769c6411864cb7e53d21a429
6
+ metadata.gz: 80cef3e80a2a47ff15b94c05486828096b29084ed54511cc534b93698578a603da8bb97b14054cef04443f02fccb49013bf439b7d6be0ebc615ce3b7d6a78c87
7
+ data.tar.gz: e687c1014bbd4f4b7e55ec2cdbc26c382b6004d8ced4f4a386842faa85b03e1efafc11a738b9e8de99862b4a8b45711e1259036ece9d7c206173804667383f25
@@ -8,10 +8,12 @@ module Moromi::Error
8
8
  }.freeze
9
9
 
10
10
  included do
11
+ class_attribute :default_moromi_error_template_path
11
12
  class_attribute :default_moromi_error_renderer_options
12
13
  class_attribute :moromi_error_logger
13
14
 
14
- self.default_moromi_error_renderer_options = {partial: ERROR_TEMPLATES[:default], layout: false}
15
+ self.default_moromi_error_template_path = ERROR_TEMPLATES[:default]
16
+ self.default_moromi_error_renderer_options = {layout: false}
15
17
  self.moromi_error_logger = Moromi::Error::DefaultLogger.new
16
18
  end
17
19
 
@@ -44,7 +46,6 @@ module Moromi::Error
44
46
  end
45
47
 
46
48
  def render_force_update(exception: Moromi::Error::NeedForceUpdate.new, options: nil, locals: {})
47
- options = options || {partial: ERROR_TEMPLATES[:default], layout: false}
48
49
  render_bad_request(exception: exception, options: options, locals: locals)
49
50
  end
50
51
 
@@ -58,7 +59,8 @@ module Moromi::Error
58
59
 
59
60
  private
60
61
 
61
- def render_error(status, title, exception, options: nil, locals: {})
62
+ def render_error(status, title, exception, options: nil, template_path: nil, locals: {})
63
+ template_path ||= self.class::default_moromi_error_template_path
62
64
  options = options || self.class::default_moromi_error_renderer_options
63
65
  e = Moromi::Error::Default.make(exception)
64
66
 
@@ -68,7 +70,7 @@ module Moromi::Error
68
70
  locals = {status: status, title: title, exception: e}.merge(locals)
69
71
 
70
72
  render_block = -> {
71
- render options.merge({locals: locals})
73
+ render template_path, **options, locals: locals
72
74
  }
73
75
 
74
76
  respond_to do |format|
@@ -1,5 +1,5 @@
1
1
  module Moromi
2
2
  module Error
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moromi-error
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,10 +128,10 @@ files:
128
128
  - LICENSE
129
129
  - README.md
130
130
  - Rakefile
131
- - app/views/moromi/error/_default.html.erb
132
- - app/views/moromi/error/_default.html.slim
133
- - app/views/moromi/error/_default.json.jb
134
- - app/views/moromi/error/_default.json.jbuilder
131
+ - app/views/moromi/error/default.html.erb
132
+ - app/views/moromi/error/default.html.slim
133
+ - app/views/moromi/error/default.json.jb
134
+ - app/views/moromi/error/default.json.jbuilder
135
135
  - bin/rails
136
136
  - config/locales/moromi-error.yml
137
137
  - lib/generators/moromi/error/views_generator.rb