coaster 1.3.24 → 1.3.26

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: 93d6eff77edc91b0d5989d307825945689cfc919db3bd239b4f78f1618613efe
4
- data.tar.gz: 427785528213c55a795202ccc1ce8f0022df964049d5c6ac19a7e3ada026addc
3
+ metadata.gz: '0508a1aac1a7bd5b88db6d62d5a928a870f5a34763fcf6e578390fd0b8b2a0e9'
4
+ data.tar.gz: ede4991485b4ca7e1df33b31087ece02ba6aa614e36d007f6c7331b31d91c166
5
5
  SHA512:
6
- metadata.gz: 8c679ef541736287ab90c0ae9cba765c3df13ee4713371bc124b36bd35e9bf48b4ed98e08dae42a1850be4f0c7d6f42e805e7062ccc0b927707ad7ff2d0910e6
7
- data.tar.gz: cd12e7dadf13ffb039c75674d82868cc9a61f086fb1f55a1bdd73a02002895eb68107359a557d7d18d343a8f768a2cd8773956f2e00c5e811a2853695cc6a605
6
+ metadata.gz: fa917d7790fa7beda1a4d7a70d188a606af266bdd26c72703af5e598a50cf74db8498835d5c4c9fc8b1f574f9ec5a2af3bdd98ee5553efa63b8b078442503091
7
+ data.tar.gz: 7e694dda54a52511f5e1c83b61d7396b33b89bfdb144799ef04dc07d4a0dd7b6c22003baaafd237800f5246a17578f8a58403db3fa6c1880008e0d2cadaa3c2a
@@ -45,6 +45,11 @@ class Object
45
45
 
46
46
  if key_class.superclass == Object || key_class == Object
47
47
  return options[:description] if options[:description].present?
48
+ case options[:fallback]
49
+ when Proc then return options[:fallback].call(self)
50
+ when Symbol then return self.send(options[:fallback])
51
+ when String then return options[:fallback]
52
+ end
48
53
  if Coaster.logger
49
54
  Coaster.logger.info(options[:original_missing])
50
55
  Coaster.logger.debug(caller.join("\n"))
@@ -214,7 +214,7 @@ class StandardError
214
214
  _h
215
215
  end
216
216
 
217
- def to_json
217
+ def to_json(options = {})
218
218
  Oj.dump(to_hash.with_indifferent_access, mode: :compat)
219
219
  end
220
220
 
@@ -1,3 +1,3 @@
1
1
  module Coaster
2
- VERSION = '1.3.24'
2
+ VERSION = '1.3.26'
3
3
  end
@@ -27,6 +27,12 @@ module Coaster
27
27
  assert_equal 'translation missing: en.class.Coaster.NotTranslated.self', NotTranslated._translate
28
28
  end
29
29
 
30
+ def test_fallback
31
+ assert_equal 'Coaster::NotTranslated', NotTranslated._translate(fallback: :name)
32
+ assert_equal 'aabbcc', NotTranslated._translate(fallback: 'aabbcc')
33
+ assert_equal 'Coaster::NotTranslated..aabb', NotTranslated._translate(fallback: proc{|klass| "#{klass.name}..aabb"})
34
+ end
35
+
30
36
  def test_raise_translation_missing
31
37
  exception = catch(:exception) do
32
38
  NotTranslated._translate(throw: true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.24
4
+ version: 1.3.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - buzz jung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-27 00:00:00.000000000 Z
11
+ date: 2023-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n