fire-model 0.0.17 → 0.0.18

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: c0292578dac18393a6a381aaa09db5f799fa291b
4
- data.tar.gz: c92f90f64fe030d036289762b53c871d52b113dd
3
+ metadata.gz: 42d53717054213dc0ec05eb3ef5ab00068da1417
4
+ data.tar.gz: a4477c961d302be3d5689da41ce7ef09ec15918b
5
5
  SHA512:
6
- metadata.gz: cf81a452c2bd1fa34a6a7728e6ad5ecb858f976c4b7d32d5356c298cbeb6f036fe97c5472cb4fc927e7cc00a39c1e2a99511f4ae66d65898fc67e564b4475714
7
- data.tar.gz: c6cfad687bd93a24e2943d4a9f397d7bd0ff2fab761d7165847fec792dd10a830311328bd930fdde5ad243081cbcbe1ac883d308408a233cc12504a7c270992c
6
+ metadata.gz: 686157d3893144651399b87bd6fa4b5765aea0cdee23c4542c3e84d78e441e239dd25a02a7423713d0b959b699b2172cfcc761866f00922abcfaed2e35d56d00
7
+ data.tar.gz: 5fe380237fb487b118f571235a293e9c227d4fc42c579e559902faacb56f2a36f5ca5916bb068667c46e157c6e714150d2978e349fa49b68e17a80a7344e7cc5
data/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  # fire-model - REST wrapper for Firebase.
2
+ [![Gem Version](https://badge.fury.io/rb/fire-model.svg)](http://badge.fury.io/rb/fire-model)
2
3
 
3
4
  Install gem
4
5
  ```
5
6
  gem install fire-model
6
7
  ```
8
+ Click [here](https://www.firebase.com/signup/) to create a free Firebase account if you don't have one.
7
9
 
8
- Setup Firebase. (If you are using Rails create a file `Rails.root/config/initializers/fire_model.rb` and put next line there)
10
+ Setup Firebase. (If you are using Rails create a file `Rails.root/config/initializers/fire_model.rb` and put next line there).
9
11
  ```ruby
10
12
  require 'fire-model'
11
- Fire.setup(firebase_path: 'https://some-test-777.firebaseio.com')
13
+ Fire.setup(firebase_path: 'https://<your subdomain here>.firebaseio.com')
12
14
  ```
13
15
 
14
16
  Declare your Model
@@ -265,6 +267,8 @@ Fire.tree
265
267
  'street'=>'Shevchenko Ave.'}}}}}})
266
268
  ```
267
269
 
270
+ ## Examples
271
+ Check [this example](https://github.com/tarvit/fire-model-example) to see how `fire-model` integrates in a Rails app.
268
272
 
269
273
  **Contributing to fire-model**
270
274
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.17
1
+ 0.0.18
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: fire-model 0.0.17 ruby lib
5
+ # stub: fire-model 0.0.18 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "fire-model"
9
- s.version = "0.0.17"
9
+ s.version = "0.0.18"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Vitaly Tarasenko"]
14
- s.date = "2015-06-28"
14
+ s.date = "2015-07-01"
15
15
  s.description = "You can define your Firebase models, set collection names, CRUD your data. "
16
16
  s.email = "vetal.tarasenko@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -35,6 +35,18 @@ module Fire
35
35
  self.class.collection_name
36
36
  end
37
37
 
38
+ def update_field(field, value)
39
+ self.send("#{field}=", value)
40
+ field_path = [path, field] * LEVEL_SEPARATOR
41
+ self.class.connection.set(field_path, value)
42
+ end
43
+
44
+ def delete_field(field)
45
+ self.send("#{field}=", nil)
46
+ field_path = [path, field] * LEVEL_SEPARATOR
47
+ self.class.connection.delete(field_path)
48
+ end
49
+
38
50
  def save
39
51
  self.class.new(@original_data).delete if path_changed?
40
52
  self.class.connection.set(path, self.saving_data)
@@ -11,7 +11,7 @@ class FireLogger < ::Logger
11
11
  end
12
12
 
13
13
  def response(response_value, path)
14
- debug "[RESPONSE] #{response_value.status}: #{ path } }"
14
+ debug "[RESPONSE] #{response_value.status}: #{ path }"
15
15
  end
16
16
 
17
17
  end
@@ -252,6 +252,44 @@ describe 'Fire Models' do
252
252
  expect(reloaded_point).to eq(p1)
253
253
  end
254
254
 
255
+ it 'should update/delete a field' do
256
+ class Box < Fire::Model
257
+ has_path_keys :a, :b
258
+ end
259
+
260
+ box = Box.create(id: 'box', a: 'a', b: 'b', slot1: 1, slot2: 2)
261
+
262
+ expect(Fire.tree).to eq({'Box'=>{'a'=>{'b'=>
263
+ {
264
+ 'box'=>{'a'=>'a', 'b'=>'b', 'id'=>'box', 'slot1'=>1, 'slot2'=>2}
265
+ }
266
+ }}})
267
+
268
+ box.update_field(:slot1, 3)
269
+
270
+ expect(Fire.tree).to eq({'Box'=>{'a'=>{'b'=>
271
+ {
272
+ 'box'=>{'a'=>'a', 'b'=>'b', 'id'=>'box', 'slot1'=>3, 'slot2'=>2}
273
+ }
274
+ }}})
275
+
276
+ box.update_field(:slot3, 4)
277
+
278
+ expect(Fire.tree).to eq({'Box'=>{'a'=>{'b'=>
279
+ {
280
+ 'box'=>{'a'=>'a', 'b'=>'b', 'id'=>'box', 'slot1'=>3, 'slot2'=>2, 'slot3'=> 4}
281
+ }
282
+ }}})
283
+
284
+ box.delete_field(:slot3)
285
+
286
+ expect(Fire.tree).to eq({'Box'=>{'a'=>{'b'=>
287
+ {
288
+ 'box'=>{'a'=>'a', 'b'=>'b', 'id'=>'box', 'slot1'=>3, 'slot2'=>2}
289
+ }
290
+ }}})
291
+ end
292
+
255
293
  end
256
294
 
257
295
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fire-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Tarasenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-28 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tarvit-helpers