t9n 0.2.0 → 0.3.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.
@@ -3,21 +3,28 @@ module Perfectline
3
3
  module Backend
4
4
  module ExceptionHandler
5
5
 
6
- def self.hoptoad_exception_handler(exception, locale, key, scope)
7
- unless defined?(HoptoadNotifier)
8
- throw RuntimeError, "HoptoadNotifier is not present, please get it from http://hoptoadapp.com/"
9
- end
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
- case exception
12
- when MissingTranslationData
13
- HoptoadNotifier.notify(exception)
14
- else
15
- raise exception
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.available_languages
6
+ def self.included(base)
7
+ base.extend(ClassMethods)
8
+ end
7
9
 
8
- unless defined?(Language)
9
- throw RuntimeError, "Language model is not defined"
10
- end
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
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t9n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanel Suurhans