liquid_queries 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/lib/liquid_queries/collection_methods.rb +12 -0
- data/lib/liquid_queries/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8699067992469cd9f9b6ef693846d262d729fb89
|
4
|
+
data.tar.gz: aea039e7770d6d1089ee66891bbd2c4296270a0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e90b6d83229fad500740651fe61676be9258e705527e30007ae0e77c94520095dd300731966d17ab2b0ca2b24ff44f4291b4ee611435257459df763b10c2d03
|
7
|
+
data.tar.gz: 1fab56107bd7e34669393855a0f1ba6ef55f3b3f06085dd0f01f1f4b54cbe1a53dcd7f2085a5c1020ca26c1999a6a37e38c3a1a8436934273c32bbef05744ac2
|
data/README.md
CHANGED
@@ -1,8 +1,35 @@
|
|
1
1
|
# LiquidQueries
|
2
|
-
|
2
|
+
|
3
|
+
Perform queries on your ActiveRecord collections directly from Liquid templates with the help of Ransack.
|
3
4
|
|
4
5
|
## Usage
|
5
|
-
|
6
|
+
|
7
|
+
Add a method to a drop that returns a collection:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
class MyDrop < Liquid::Drop
|
11
|
+
def users
|
12
|
+
LiquidQueries::Collection.new(collection: User.all)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
Then do something like this in your Liquid template:
|
18
|
+
|
19
|
+
```liquid
|
20
|
+
Kasper's ID is: {{ my_drop.users.ransack.first_name_eq.Kasper.first.id }}
|
21
|
+
Kasper's last name is {{ my_drop.users.ransack.first_name_eq.Kasper.first.last_name }}
|
22
|
+
```
|
23
|
+
|
24
|
+
Or something like this:
|
25
|
+
|
26
|
+
```liquid
|
27
|
+
Users with a name that contains "kasper":
|
28
|
+
|
29
|
+
{% for user in my_drop.users.ransack.name_cont.kasper %}
|
30
|
+
{{ user.id }} - {{ user.first_name }} {{ user.last_name }}
|
31
|
+
{% endfor %}
|
32
|
+
```
|
6
33
|
|
7
34
|
## Installation
|
8
35
|
Add this line to your application's Gemfile:
|
@@ -3,6 +3,10 @@ module LiquidQueries::CollectionMethods
|
|
3
3
|
collection
|
4
4
|
end
|
5
5
|
|
6
|
+
def empty?
|
7
|
+
collection.empty?
|
8
|
+
end
|
9
|
+
|
6
10
|
def first
|
7
11
|
collection.first
|
8
12
|
end
|
@@ -11,7 +15,15 @@ module LiquidQueries::CollectionMethods
|
|
11
15
|
collection.last
|
12
16
|
end
|
13
17
|
|
18
|
+
def pop
|
19
|
+
collection.pop
|
20
|
+
end
|
21
|
+
|
14
22
|
def ransack
|
15
23
|
LiquidQueries::RansackQuery.new(collection: collection)
|
16
24
|
end
|
25
|
+
|
26
|
+
def shift
|
27
|
+
collection.shift
|
28
|
+
end
|
17
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid_queries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|