dm-json-search 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -7
- data/VERSION +1 -1
- data/dm-json-search.gemspec +1 -1
- data/lib/dm-json-search.rb +4 -1
- data/lib/dm-json-search/searchable.rb +2 -7
- metadata +1 -1
data/README
CHANGED
@@ -8,15 +8,9 @@ gem install gemcutter # unless you already have
|
|
8
8
|
gem tumble # unless you already have
|
9
9
|
gem install dm-json-search
|
10
10
|
|
11
|
-
Then, in your model:
|
12
|
-
|
13
|
-
class Book
|
14
|
-
include JsonSearch::Searchable
|
15
|
-
end
|
16
|
-
|
17
11
|
Wala:
|
18
12
|
|
19
|
-
Book.
|
13
|
+
Book.all_from_json('[{"eql":{"title":"Psycho"}}]')
|
20
14
|
# Should this be mixed in automagically to every model?
|
21
15
|
|
22
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/dm-json-search.gemspec
CHANGED
data/lib/dm-json-search.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
1
|
require 'dm-core'
|
2
2
|
require File.dirname(__FILE__) + '/dm-json-search/query_ext'
|
3
|
-
require File.dirname(__FILE__) + '/dm-json-search/searchable'
|
3
|
+
require File.dirname(__FILE__) + '/dm-json-search/searchable'
|
4
|
+
|
5
|
+
DataMapper::Model.append_extensions(JsonSearch::Searchable::ClassMethods)
|
6
|
+
# DataMapper::Model.append_inclusions(JsonSearch::Searchable::ClassMethods)
|
@@ -1,12 +1,8 @@
|
|
1
1
|
module JsonSearch
|
2
2
|
module Searchable
|
3
3
|
|
4
|
-
def self.included(base)
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
end
|
7
|
-
|
8
4
|
module ClassMethods
|
9
|
-
def
|
5
|
+
def all_from_json(json = {})
|
10
6
|
json = JSON.parse(json) if json.is_a?(String)
|
11
7
|
|
12
8
|
if json.is_a?(Array)
|
@@ -25,5 +21,4 @@ module JsonSearch
|
|
25
21
|
end
|
26
22
|
|
27
23
|
end
|
28
|
-
end
|
29
|
-
JSONSearch = JsonSearch
|
24
|
+
end
|