awesome_hstore_translate 0.2.0 → 0.2.1

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: 776affdef8d15b23476763a402444c5cd9d77f52
4
- data.tar.gz: 119148870bf3a17cda07f86c017652c742345aae
3
+ metadata.gz: 3b7a102f4de133d326d96a0b697f2c546409ce88
4
+ data.tar.gz: 032d0828417f873bb3b4772fb4da311baa937b38
5
5
  SHA512:
6
- metadata.gz: f1c7928bd63ef520c96de9183905e2008a7140fd43644cb7499b1eec466c464555104dfba7b041a9e2fb4fdf77a59e31638dcbcb400ee68a730d092b8898c8e6
7
- data.tar.gz: 6123dae82312fa213b1b4cc7160d02276846c281d48755537a3acdc579d83cdc8b923f3af462464ced517995a79b8b3ebf23b2873c452b29e34fac5bf90235ae
6
+ metadata.gz: 732b84d4d47e6ed0137746a7947834bf75884195db19700b0962337197e4e4e49f42571568f5778371fc73e34812e8789296e4fff914e05e09dd5936f05c004c
7
+ data.tar.gz: f008e5892a26270fb68ae2773e90d1036d33bcfe8f5ad50a558403742cb8592833f7727ed71af701c3201263745d3d7d492ac4d599646bb481aa968e9033d97a
data/README.md CHANGED
@@ -15,8 +15,7 @@ This gem uses PostgreSQLs hstore datatype and ActiveRecord models to translate m
15
15
  - [x] `v0.1.0` Language specific accessors
16
16
  - [x] `v0.2.0` Awesome Hstore Translate as drop in replace for [`hstore_translate`](https://github.com/Leadformance/hstore_translate)
17
17
  - `with_[attr]_translation(str)` is not supported
18
- - [x] `v0.2.0` Support record selection via ActiveRecord (e. g. `where`, `find_by`)
19
- - maybe it's a bad idea to implement this
18
+ - [x] `v0.2.0` Support record selection via ActiveRecord (e. g. `where`, `find_by`, ..)
20
19
  - [ ] `backlog` Support `friendly_id` (see `friendly_id-awesome_hstore` gem)
21
20
 
22
21
  ## Requirements
@@ -83,7 +82,7 @@ p.title_raw # => {'en' => 'English title', 'de' => 'Deutscher Titel'}
83
82
 
84
83
 
85
84
  ### Fallbacks
86
- To enable fallbacks you can set `I18n.fallbacks` to `true` or enable it manually in the model:
85
+ It's possible to fall back to another language, if there is no or an empty value for the primary language. To enable fallbacks you can set `I18n.fallbacks` to `true` or enable it manually in the model:
87
86
  ```ruby
88
87
  class Page < ActiveRecord::Base
89
88
  translates :title, :content, fallbacks: true
@@ -1,15 +1,8 @@
1
1
  module AwesomeHstoreTranslate
2
2
  module ActiveRecord
3
3
  module QueryMethods
4
- class WhereChain < ::ActiveRecord::QueryMethods::WhereChain
5
- end
6
-
7
4
  def where(opts = :chain, *rest)
8
- if opts == :chain
9
- WhereChain.new(spawn)
10
- elsif opts.blank?
11
- return self
12
- elsif opts.is_a?(Hash)
5
+ if opts.is_a?(Hash)
13
6
  translated_attrs = translated_attributes(opts)
14
7
  normal_attrs = opts.reject{ |key, _| translated_attrs.include? key}
15
8
  query = spawn
@@ -19,12 +12,13 @@ module AwesomeHstoreTranslate
19
12
  if opts[attribute].is_a?(String)
20
13
  query.where!("'#{opts[attribute]}' = any(avals(#{attribute}))")
21
14
  else
22
- super(opts, rest)
15
+ super
23
16
  end
24
17
  end
25
- return query
18
+ query
19
+ else
20
+ super
26
21
  end
27
- super(opts, rest)
28
22
  end
29
23
 
30
24
  private
@@ -1,3 +1,3 @@
1
1
  module AwesomeHstoreTranslate
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_hstore_translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Bühler