t9n 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/t9n/backend/exception_handler.rb +18 -11
- data/lib/t9n/backend/extension.rb +16 -10
- metadata +1 -1
@@ -3,21 +3,28 @@ module Perfectline
|
|
3
3
|
module Backend
|
4
4
|
module ExceptionHandler
|
5
5
|
|
6
|
-
def self.
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def hoptoad_exception_handler(exception, locale, key, scope)
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
unless defined?(HoptoadNotifier)
|
14
|
+
raise RuntimeError, "HoptoadNotifier is not present, please get it from http://hoptoadapp.com/"
|
15
|
+
end
|
16
|
+
|
17
|
+
case exception
|
18
|
+
when MissingTranslationData
|
19
|
+
HoptoadNotifier.notify(exception)
|
20
|
+
else
|
21
|
+
raise exception
|
22
|
+
end
|
23
|
+
|
24
|
+
return exception.message
|
16
25
|
end
|
17
26
|
|
18
|
-
return exception.message
|
19
27
|
end
|
20
|
-
|
21
28
|
end
|
22
29
|
end
|
23
30
|
end
|
@@ -3,22 +3,28 @@ module Perfectline
|
|
3
3
|
module Backend
|
4
4
|
module Extension
|
5
5
|
|
6
|
-
def self.
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
module ClassMethods
|
11
|
+
def available_languages
|
12
|
+
|
13
|
+
unless defined?(Language)
|
14
|
+
raise RuntimeError, "Language model is not defined"
|
15
|
+
end
|
16
|
+
|
17
|
+
if self.backend.respond_to?(:available_languages)
|
18
|
+
self.backend.available_languages
|
19
|
+
end
|
11
20
|
|
12
|
-
if self.backend.respond_to?(:available_languages)
|
13
|
-
self.backend.available_languages
|
14
21
|
end
|
15
22
|
|
16
|
-
|
23
|
+
def default_locale?(locale = nil)
|
24
|
+
locale.nil? ? default_locale == self.locale : default_locale == locale.to_sym
|
25
|
+
end
|
17
26
|
|
18
|
-
def self.default_locale?(locale = nil)
|
19
|
-
locale.nil? ? default_locale == self.locale : default_locale == locale.to_sym
|
20
27
|
end
|
21
|
-
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|