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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7e38eaafcd681f7aa78b56427f07460f7b995ce
4
- data.tar.gz: 62b77800ad18af59905506a5a65fc30285a14299
3
+ metadata.gz: 2c84301d2ecd421dcefc6f2783adf3256e8c4764
4
+ data.tar.gz: b3469da9b842c321e1dd6241e1f7f3b61f171fa7
5
5
  SHA512:
6
- metadata.gz: 473fbcc6e40aab4c828478959896d90e8403a96eca495c0df31bb8d9b2faa0e2e49fe3ecd8913035c38c3a69004284f17be963e1cb3aae1744a0f3191df69479
7
- data.tar.gz: 31545c9e848c7c60ee7ef638063ed66999cded527ba115f943e7acbf84c72ae1944094a3e10a871131ee4ff35a52baf2640d5b1c22d01fc7daad5c5c8cd42e5d
6
+ metadata.gz: 9bd9d7c183fd82404f59b2c9c797628f061bba52ba788e02abde15519ce9694ee73e17f5906eb3972f8e4f255ffb580711d9fb8d522365f649fe89d0855b34a6
7
+ data.tar.gz: 397f40c255c47e8f79f62eac57bcce2372e4ee7ed5031d38d47503367ef9f712a300b4d8727a258b16f6b89834d73ce24fef9f3c44dfbd5e04388a04dbf0f024
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ;%����.ϳ�\���퇭Ҝ��3л\8h���n�ݣp�װ'%gג�kC J�Bz����]3�+x!�K �����v�����wh�jC#�l�> {K���������߭���>��@.:˕&;؇��� ���9gwdGP.K
2
- A��AV�-
1
+ g�t������e�݆�A���9�a�P���9d&c�H
2
+ ��֙��ӎ�a�Ԣ!��
@@ -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))
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (0.3.3)
4
+ mobility (0.4.0.alpha.1)
5
5
  i18n (>= 0.6.10, < 0.10)
6
6
  request_store (~> 1.0)
7
7
 
@@ -148,4 +148,4 @@ DEPENDENCIES
148
148
  yard (~> 0.9.0)
149
149
 
150
150
  BUNDLED WITH
151
- 1.16.0.pre.2
151
+ 1.16.0
data/README.md CHANGED
@@ -54,7 +54,7 @@ Installation
54
54
  Add this line to your application's Gemfile:
55
55
 
56
56
  ```ruby
57
- gem 'mobility', '~> 0.3.4'
57
+ gem 'mobility', '~> 0.3.5'
58
58
  ```
59
59
 
60
60
  Mobility is cryptographically signed. To be sure the gem you install hasn't
@@ -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 proc, it is passed a hash with four keyword arguments:
9
- - +model+: the model instance
10
- - +attribute+: the attribute name (a String)
11
- - +locale+: the locale (a Symbol)
12
- - +options+: hash of options passed in to accessor
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:, locale:| "#{attribute} in #{locale}" }
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 { |model:| model.class.name.to_s })
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
- default.call(model: model,
74
- attribute: attribute,
75
- locale: locale,
76
- options: options)
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
@@ -1,3 +1,3 @@
1
1
  module Mobility
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
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
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-06 00:00:00.000000000 Z
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.13
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