motion-firebase 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -8
- data/lib/firebase/fquery.rb +8 -2
- data/lib/firebase/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60e59da0ad361fda56da106ad5b317dff1413fd5
|
4
|
+
data.tar.gz: d46db22cead3e0f4455a59507d3c1812a5465963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ab1a76883b13ed95f00d53986f644626a045bd8b657a2e162202c665a66973777a106ab4a5aefa3f9937e85524704385561145db9badea931765c2b7bb71a8c
|
7
|
+
data.tar.gz: 283046efed7b4599fd7d21a681b13b6adc88874098001a754d217108689135bdb4c21f19560719fa88b30d77dfdb1906cd081861ada08de28756e3a6f6c53edd
|
data/README.md
CHANGED
@@ -159,19 +159,21 @@ firebase.limit(limit)
|
|
159
159
|
|
160
160
|
##### Querying
|
161
161
|
|
162
|
-
|
163
|
-
|
164
|
-
# => firebase.queryOrderedByKey
|
165
|
-
|
166
|
-
firebase.query(order_by_priority: true)
|
167
|
-
# => firebase.queryOrderedByPriority
|
162
|
+
These methods were added to Firebase in version 2.0.1. NB: You can provide a
|
163
|
+
block and `on: event` value to create a listener.
|
168
164
|
|
165
|
+
```ruby
|
169
166
|
firebase.query(order_by: 'key')
|
170
167
|
# => firebase.queryOrderedByChild('key')
|
171
168
|
|
172
169
|
firebase.query(first: value)
|
173
170
|
# => firebase.queryLimitedToFirst(value)
|
174
171
|
|
172
|
+
# create a listener by providing a block and :on value (default is :value if :on
|
173
|
+
# isn't specified)
|
174
|
+
firebase.query(first: value, on: :added) do |snapshot|
|
175
|
+
end
|
176
|
+
|
175
177
|
firebase.query(last: value)
|
176
178
|
# => firebase.queryLimitedToLast(value)
|
177
179
|
|
@@ -190,14 +192,19 @@ firebase.query(equal_to: value, child: 'key')
|
|
190
192
|
# => firebase.queryEqualToValue(value)
|
191
193
|
# => firebase.queryEqualToValue(value, childKey: 'key')
|
192
194
|
|
195
|
+
firebase.query(order_by_key: true)
|
196
|
+
# => firebase.queryOrderedByKey
|
197
|
+
|
198
|
+
firebase.query(order_by_priority: true)
|
199
|
+
# => firebase.queryOrderedByPriority
|
200
|
+
|
193
201
|
# and of course these can all be combined into one call:
|
194
202
|
firebase.query(
|
195
|
-
first: 5,
|
203
|
+
first: 5,
|
196
204
|
starting_at: 'foo',
|
197
205
|
ending_at: 'bar')
|
198
206
|
|
199
207
|
# => firebase.queryLimitedToFirst(5)
|
200
|
-
# .queryLimitedToLast(6)
|
201
208
|
# .queryStartingAtValue('foo')
|
202
209
|
# .queryEndingAtValue('bar')
|
203
210
|
|
data/lib/firebase/fquery.rb
CHANGED
@@ -93,7 +93,7 @@ class FQuery
|
|
93
93
|
queryLimitedToNumberOfChildren(limit)
|
94
94
|
end
|
95
95
|
|
96
|
-
def query(options={})
|
96
|
+
def query(options={}, &block)
|
97
97
|
fb_query = self
|
98
98
|
|
99
99
|
if options[:order_by_key]
|
@@ -134,7 +134,13 @@ class FQuery
|
|
134
134
|
fb_query = fb_query.queryEqualToValue(options[:equal_to])
|
135
135
|
end
|
136
136
|
|
137
|
-
|
137
|
+
if block
|
138
|
+
event_type = options.fetch(:on, FEventTypeValue)
|
139
|
+
event_type = Firebase.convert_event_type(event_type)
|
140
|
+
return fb_query.observeEventType(event_type, withBlock: and_then)
|
141
|
+
else
|
142
|
+
fb_query
|
143
|
+
end
|
138
144
|
end
|
139
145
|
|
140
146
|
end
|
data/lib/firebase/version.rb
CHANGED