mobility 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/mobility/plugins/default.rb +18 -11
- data/lib/mobility/version.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c84301d2ecd421dcefc6f2783adf3256e8c4764
|
4
|
+
data.tar.gz: b3469da9b842c321e1dd6241e1f7f3b61f171fa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bd9d7c183fd82404f59b2c9c797628f061bba52ba788e02abde15519ce9694ee73e17f5906eb3972f8e4f255ffb580711d9fb8d522365f649fe89d0855b34a6
|
7
|
+
data.tar.gz: 397f40c255c47e8f79f62eac57bcce2372e4ee7ed5031d38d47503367ef9f712a300b4d8727a258b16f6b89834d73ce24fef9f3c44dfbd5e04388a04dbf0f024
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
� g�t������e�݆�A���9�a�P���9d&c�H
|
2
|
+
��֙��ӎ�a�Ԣ!��
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## 0.3
|
4
4
|
|
5
|
+
### 0.3.5 (December 24, 2017)
|
6
|
+
* Make Default plugin handle Procs more gracefully
|
7
|
+
([#137](https://github.com/shioyama/mobility/pull/137))
|
8
|
+
* Show deprecation warning if keyword options passed to Default plugin
|
9
|
+
([#147](https://github.com/shioyama/mobility/pull/147))
|
10
|
+
|
5
11
|
### 0.3.4 (December 6, 2017)
|
6
12
|
* Move `translated_attribute_names` to `Mobility::ActiveRecord`
|
7
13
|
([#132](https://github.com/shioyama/mobility/pull/129))
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -5,11 +5,12 @@ module Mobility
|
|
5
5
|
Defines value or proc to fall through to if return value from getter would
|
6
6
|
otherwise be nil.
|
7
7
|
|
8
|
-
If default is a
|
9
|
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
8
|
+
If default is a +Proc+, it will be called with the context of the model, and
|
9
|
+
passed arguments:
|
10
|
+
- the attribute name (a String)
|
11
|
+
- the locale (a Symbol)
|
12
|
+
- hash of options passed in to accessor
|
13
|
+
The proc can accept zero to three arguments (see examples below)
|
13
14
|
|
14
15
|
@example With default enabled (falls through to default value)
|
15
16
|
class Post
|
@@ -46,7 +47,7 @@ If default is a proc, it is passed a hash with four keyword arguments:
|
|
46
47
|
@example Using Proc as default
|
47
48
|
class Post
|
48
49
|
extend Mobility
|
49
|
-
translates :title, default: lambda { |attribute
|
50
|
+
translates :title, default: lambda { |attribute, locale| "#{attribute} in #{locale}" }
|
50
51
|
end
|
51
52
|
|
52
53
|
Mobility.locale = :en
|
@@ -54,7 +55,7 @@ If default is a proc, it is passed a hash with four keyword arguments:
|
|
54
55
|
post.title
|
55
56
|
#=> "title in en"
|
56
57
|
|
57
|
-
post.title(default: lambda {
|
58
|
+
post.title(default: lambda { self.class.name.to_s })
|
58
59
|
#=> "Post"
|
59
60
|
=end
|
60
61
|
class Default < Module
|
@@ -70,10 +71,16 @@ If default is a proc, it is passed a hash with four keyword arguments:
|
|
70
71
|
default = options.has_key?(:default) ? options.delete(:default) : default_option
|
71
72
|
if (value = super(locale, options)).nil?
|
72
73
|
return default unless default.is_a?(Proc)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
# TODO: Remove in v1.0
|
75
|
+
if default.parameters.any? { |n, v| [:keyreq, :keyopt].include?(n) && [:model, :attribute, :locale, :options].include?(v) }
|
76
|
+
warn %{
|
77
|
+
WARNING: Passing keyword arguments to a Proc in the Default plugin is
|
78
|
+
deprecated. See the API documentation for details.}
|
79
|
+
return default.call(model: model, attribute: attribute, locale: locale, options: options)
|
80
|
+
end
|
81
|
+
args = [attribute, locale, options]
|
82
|
+
args = args.first(default.arity) unless default.arity < 0
|
83
|
+
model.instance_exec(*args, &default)
|
77
84
|
else
|
78
85
|
value
|
79
86
|
end
|
data/lib/mobility/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Salzberg
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
eGDROPZoL5RXwiOnRbexxa7dcAxMrDfGB/hpiunIPWPsi4n5P7K/6OO/sGVMl9xv
|
31
31
|
SZBPXjzrHdyOFLBYXB+PG7s3F/4=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2017-12-
|
33
|
+
date: 2017-12-24 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: request_store
|
@@ -284,7 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
284
284
|
version: '0'
|
285
285
|
requirements: []
|
286
286
|
rubyforge_project:
|
287
|
-
rubygems_version: 2.6.
|
287
|
+
rubygems_version: 2.6.11
|
288
288
|
signing_key:
|
289
289
|
specification_version: 4
|
290
290
|
summary: Pluggable Ruby translation framework
|
metadata.gz.sig
CHANGED
Binary file
|