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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7013544f3915514408c9cd0e5d26b30430a8d627
4
- data.tar.gz: 1c07a8bf3388e49d5d592fc2490e5bf7f6e76aac
3
+ metadata.gz: 60e59da0ad361fda56da106ad5b317dff1413fd5
4
+ data.tar.gz: d46db22cead3e0f4455a59507d3c1812a5465963
5
5
  SHA512:
6
- metadata.gz: b93a6c8dffc7ba0b852bb2dcd9e57e0bf5a7d5c34ff4f6892b7c6538215f5dd3c81f1bf960bae10846e9a7f8bd025d36172049144dd4378ae0160ff9bad7818e
7
- data.tar.gz: c49f30050e8f6c0c91f88c8d13fb5c096c3102b62d9cd1757ced67cfedb63092ba1eeb5e4ca6b7f52b7a2fa54e5acfa1025be2636c47cfde7029372d3effb58d
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
- ```ruby
163
- firebase.query(order_by_key: true)
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, # last: 6,
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
 
@@ -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
- fb_query
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
@@ -1,6 +1,6 @@
1
1
  module Motion
2
2
  module Firebase
3
- Version = '3.1.0' # motion-firebase gem version
3
+ Version = '3.1.1' # motion-firebase gem version
4
4
  SdkVersion = '1.2.2' # firebase framework version
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-firebase
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray