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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62d648cae4463ebb3847f54e80987de10a8f630d
4
- data.tar.gz: aff5e7a2a3039cc1d4b4342619a459638c87b7b6
3
+ metadata.gz: 8699067992469cd9f9b6ef693846d262d729fb89
4
+ data.tar.gz: aea039e7770d6d1089ee66891bbd2c4296270a0d
5
5
  SHA512:
6
- metadata.gz: 0d8673af4538ff2e238eb6a24cd06b11d6147b11e50fcfbc5384d6db225936d55b4641174e986905c04a005e649307ba0fe6f590204a96448eeaaf5e32a8407f
7
- data.tar.gz: 22e42236832e3c47d8aab5caefb63cac9a93eda5d94a3277d15cbaabd8c6c4b9a3d2537d9cb25c526f487f7bc61b8428aaecd15582e7171a0bfa86ae6aa902e5
6
+ metadata.gz: 1e90b6d83229fad500740651fe61676be9258e705527e30007ae0e77c94520095dd300731966d17ab2b0ca2b24ff44f4291b4ee611435257459df763b10c2d03
7
+ data.tar.gz: 1fab56107bd7e34669393855a0f1ba6ef55f3b3f06085dd0f01f1f4b54cbe1a53dcd7f2085a5c1020ca26c1999a6a37e38c3a1a8436934273c32bbef05744ac2
data/README.md CHANGED
@@ -1,8 +1,35 @@
1
1
  # LiquidQueries
2
- Short description and motivation.
2
+
3
+ Perform queries on your ActiveRecord collections directly from Liquid templates with the help of Ransack.
3
4
 
4
5
  ## Usage
5
- How to use my plugin.
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
@@ -1,3 +1,3 @@
1
1
  module LiquidQueries
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.2".freeze
3
3
  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.1
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-01 00:00:00.000000000 Z
11
+ date: 2017-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails