tire 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tire/model/search.rb +4 -4
- data/lib/tire/version.rb +3 -2
- data/test/unit/model_search_test.rb +13 -0
- metadata +6 -5
data/lib/tire/model/search.rb
CHANGED
@@ -23,6 +23,10 @@ module Tire
|
|
23
23
|
define_method("#{attr}=") { |value| @attributes ||= {}; @attributes[attr] = value }
|
24
24
|
define_method("#{attr}") { @attributes[attr] }
|
25
25
|
end
|
26
|
+
|
27
|
+
def to_hash
|
28
|
+
self.serializable_hash
|
29
|
+
end unless instance_methods.map(&:to_sym).include?(:to_hash)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
@@ -92,10 +96,6 @@ module Tire
|
|
92
96
|
end
|
93
97
|
end
|
94
98
|
|
95
|
-
def to_hash
|
96
|
-
self.serializable_hash
|
97
|
-
end
|
98
|
-
|
99
99
|
def to_indexed_json
|
100
100
|
if self.class.mapping.empty?
|
101
101
|
to_hash.to_json
|
data/lib/tire/version.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module Tire
|
2
|
-
VERSION = "0.1.
|
2
|
+
VERSION = "0.1.12"
|
3
3
|
|
4
4
|
CHANGELOG =<<-END
|
5
|
-
CHANGES
|
5
|
+
IMPORTANT CHANGES LATELY:
|
6
6
|
|
7
7
|
# Added `<after/before>_update_elastic_search_index` callbacks for models
|
8
8
|
# Search performs GET instead of POST
|
9
9
|
# Added percolator support
|
10
10
|
# Added percolator support for models
|
11
11
|
# CHANGELOG support in gemspec
|
12
|
+
# [FIX] Do not redefine #to_hash in models
|
12
13
|
END
|
13
14
|
end
|
@@ -311,6 +311,19 @@ module Tire
|
|
311
311
|
assert_equal( {'title' => 'Test'}, ActiveModelArticle.new( 'title' => 'Test' ).to_hash )
|
312
312
|
end
|
313
313
|
|
314
|
+
should "not redefine to_hash if already defined" do
|
315
|
+
class ::ActiveModelArticleWithToHash < ActiveModelArticle
|
316
|
+
def to_hash; { :foo => 'bar' }; end
|
317
|
+
end
|
318
|
+
assert_equal 'bar', ::ActiveModelArticleWithToHash.new(:title => 'Test').to_hash[:foo]
|
319
|
+
|
320
|
+
class ::ActiveModelArticleWithToHashFromSuperclass < Hash
|
321
|
+
include Tire::Model::Search
|
322
|
+
include Tire::Model::Callbacks
|
323
|
+
end
|
324
|
+
assert_equal( {}, ::ActiveModelArticleWithToHashFromSuperclass.new(:title => 'Test').to_hash)
|
325
|
+
end
|
326
|
+
|
314
327
|
should "serialize itself into JSON without 'root'" do
|
315
328
|
@model = ActiveModelArticle.new 'title' => 'Test'
|
316
329
|
assert_equal({'title' => 'Test'}.to_json, @model.to_indexed_json)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 12
|
10
|
+
version: 0.1.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Karel Minarik
|
@@ -347,15 +347,16 @@ post_install_message: |
|
|
347
347
|
|
348
348
|
--------------------------------------------------------------------------------
|
349
349
|
|
350
|
-
CHANGES
|
350
|
+
IMPORTANT CHANGES LATELY:
|
351
351
|
|
352
352
|
# Added `<after/before>_update_elastic_search_index` callbacks for models
|
353
353
|
# Search performs GET instead of POST
|
354
354
|
# Added percolator support
|
355
355
|
# Added percolator support for models
|
356
356
|
# CHANGELOG support in gemspec
|
357
|
+
# [FIX] Do not redefine #to_hash in models
|
357
358
|
|
358
|
-
See the full changelog at <http://github.com/karmi/tire/commits/v0.1.
|
359
|
+
See the full changelog at <http://github.com/karmi/tire/commits/v0.1.12>.
|
359
360
|
|
360
361
|
--------------------------------------------------------------------------------
|
361
362
|
|