mobility 0.8.4 → 0.8.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
  SHA256:
3
- metadata.gz: 733ca7a4894cdebcc0cefe533129793b6648d19c5c9f57f837b3660f8ac704f6
4
- data.tar.gz: 7fc756a3e7b7278702b43c9ecbdf12d904000a960037cee8bbba0bc0b4b3ee3a
3
+ metadata.gz: 9a4242439552faaeb722300168bed5974112ff0f9a66452073b9f30e4a898f08
4
+ data.tar.gz: 14d4bf01f2bed2faa7d795f809707453a44183f50516465dfeb0155bb7ce2061
5
5
  SHA512:
6
- metadata.gz: 30bbaa926ac3aef1fa1f438120f20c47077f97412ae24140b4a827cc1862f1ebf9cf0d24caf1caae2362f12af1e46ca6251848f012dfbd606aa603e682c0af91
7
- data.tar.gz: c30e9bfbd12036581a03cca35488a068832f33928a91c337f27fd2ccf25908cc8363c3d20b95fa60c8ed0792ed6ce3fc0d8d49c55e8874f7a4a41cbc8693fee5
6
+ metadata.gz: 2b36d734faa10f98f87283f1b4a6577c6ba10762d175383ef0ca30c3fedb7b645595b2db02d63800a1545d9ddbcc537dea0ab00b7e31b36473bf625079654bf7
7
+ data.tar.gz: 47e035ddd560973c01a64525f6206268eadfce2a38728b6195fae59cecc3822f61ccf72a824bcd14d29028fd943cf89a16d9c61c202a9e2a083cc7bc59125c71
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 0.8
4
4
 
5
+ ### 0.8.5 (November 1, 2018)
6
+ * Load column_type when building node
7
+ ([#301](https://github.com/shioyama/mobility/pull/301))
8
+
5
9
  ### 0.8.4 (October 19, 2018)
6
10
  * Use references to define polymorphic associations in generator migrations
7
11
  ([#292](https://github.com/shioyama/mobility/pull/292))
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (0.8.2)
4
+ mobility (1.0.alpha.1)
5
5
  i18n (>= 0.6.10, < 2)
6
6
  request_store (~> 1.0)
7
7
 
@@ -61,7 +61,7 @@ GEM
61
61
  guard (~> 2.1)
62
62
  guard-compat (~> 1.1)
63
63
  rspec (>= 2.99.0, < 4.0)
64
- i18n (1.1.0)
64
+ i18n (1.1.1)
65
65
  concurrent-ruby (~> 1.0)
66
66
  listen (3.1.5)
67
67
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -76,7 +76,7 @@ GEM
76
76
  minitest (5.11.3)
77
77
  mysql2 (0.4.10)
78
78
  nenv (0.3.0)
79
- nokogiri (1.8.4)
79
+ nokogiri (1.8.5)
80
80
  mini_portile2 (~> 2.3.0)
81
81
  notiffany (0.1.1)
82
82
  nenv (~> 0.1)
@@ -114,7 +114,7 @@ GEM
114
114
  rspec-mocks (~> 3.8.0)
115
115
  rspec-core (3.8.0)
116
116
  rspec-support (~> 3.8.0)
117
- rspec-expectations (3.8.1)
117
+ rspec-expectations (3.8.2)
118
118
  diff-lcs (>= 1.2.0, < 2.0)
119
119
  rspec-support (~> 3.8.0)
120
120
  rspec-mocks (3.8.0)
data/README.md CHANGED
@@ -51,7 +51,7 @@ Installation
51
51
  Add this line to your application's Gemfile:
52
52
 
53
53
  ```ruby
54
- gem 'mobility', '~> 0.8.4'
54
+ gem 'mobility', '~> 0.8.5'
55
55
  ```
56
56
 
57
57
  Mobility is cryptographically signed. To be sure the gem you install hasn't
@@ -17,10 +17,6 @@ Implements the {Mobility::Backends::Container} backend for ActiveRecord models.
17
17
  # @return [Symbol] (:translations) Name of translations column
18
18
  option_reader :column_name
19
19
 
20
- # @!method column_type
21
- # @return [Symbol] Either :json or :jsonb
22
- option_reader :column_type
23
-
24
20
  # @!group Backend Accessors
25
21
  #
26
22
  # @note Translation may be a string, integer, boolean, hash or array
@@ -44,30 +40,42 @@ Implements the {Mobility::Backends::Container} backend for ActiveRecord models.
44
40
  end
45
41
  # @!endgroup
46
42
 
47
- # @!group Backend Configuration
48
- # @option options [Symbol] column_name (:translations) Name of column on which to store translations
49
- # @raise [InvalidColumnType] if the type of the container column is not json or jsonb
50
- def self.configure(options)
51
- options[:column_name] ||= :translations
52
- options[:column_name] = options[:column_name].to_sym
53
- options[:column_type] = options[:model_class].type_for_attribute(options[:column_name].to_s).try(:type)
54
- unless %i[json jsonb].include?(options[:column_type])
55
- raise InvalidColumnType, "#{options[:column_name]} must be a column of type json or jsonb"
43
+ class << self
44
+ # @!group Backend Configuration
45
+ # @option options [Symbol] column_name (:translations) Name of column on which to store translations
46
+ # @raise [InvalidColumnType] if the type of the container column is not json or jsonb
47
+ def configure(options)
48
+ options[:column_name] ||= :translations
49
+ options[:column_name] = options[:column_name].to_sym
50
+ end
51
+ # @!endgroup
52
+
53
+ # @param [String] attr Attribute name
54
+ # @param [Symbol] locale Locale
55
+ # @return [Mobility::Arel::Nodes::Json,Mobility::Arel::Nodes::Jsonb] Arel
56
+ # node for attribute on json or jsonb column
57
+ def build_node(attr, locale)
58
+ column = model_class.arel_table[column_name]
59
+ case column_type
60
+ when :json
61
+ Arel::Nodes::JsonContainer.new(column, build_quoted(locale), build_quoted(attr))
62
+ when :jsonb
63
+ Arel::Nodes::JsonbContainer.new(column, build_quoted(locale), build_quoted(attr))
64
+ end
56
65
  end
57
- end
58
- # @!endgroup
59
66
 
60
- # @param [String] attr Attribute name
61
- # @param [Symbol] locale Locale
62
- # @return [Mobility::Arel::Nodes::Json,Mobility::Arel::Nodes::Jsonb] Arel
63
- # node for attribute on json or jsonb column
64
- def self.build_node(attr, locale)
65
- column = model_class.arel_table[column_name]
66
- case column_type
67
- when :json
68
- Arel::Nodes::JsonContainer.new(column, build_quoted(locale), build_quoted(attr))
69
- when :jsonb
70
- Arel::Nodes::JsonbContainer.new(column, build_quoted(locale), build_quoted(attr))
67
+ def column_type
68
+ @column_type ||= get_column_type
69
+ end
70
+
71
+ private
72
+
73
+ def get_column_type
74
+ options[:model_class].type_for_attribute(options[:column_name].to_s).try(:type).tap do |type|
75
+ unless %i[json jsonb].include? type
76
+ raise InvalidColumnType, "#{options[:column_name]} must be a column of type json or jsonb"
77
+ end
78
+ end
71
79
  end
72
80
  end
73
81
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mobility
4
- VERSION = "0.8.4"
4
+ VERSION = "0.8.5"
5
5
  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.8.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -35,7 +35,7 @@ cert_chain:
35
35
  m46ezJjnr4uXgSNuTs+RdM6DtrKaFG2HuziSP+dzmWqZiUgj1eTACYsPwfF/Z1Z6
36
36
  2DiDkec/SK4qJBMlNYPo/PTZuh5m1jROtf/hyS0VXJmm+uWc
37
37
  -----END CERTIFICATE-----
38
- date: 2018-10-19 00:00:00.000000000 Z
38
+ date: 2018-10-31 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: request_store
metadata.gz.sig CHANGED
Binary file