reactive-record 0.8.1 → 0.8.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 +14 -3
- data/lib/reactive_record/active_record/instance_methods.rb +10 -0
- data/lib/reactive_record/active_record/reactive_record/collection.rb +1 -1
- data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +10 -0
- data/lib/reactive_record/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32c824a576a794dbab1d8726018b1aae835d8d70
|
4
|
+
data.tar.gz: 15d0d3851ad5ed3bc6fc391b6b425c37d8e455cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dee4ae8c6ee53a0edbbe993d1ef86b2c2eb60b27829b67bda50cacf4d074981e7dbae93004812ca75c9a44a9d8ada3c8436d0a526cc96069edf2607e49060c90
|
7
|
+
data.tar.gz: dadcfc8afaa837a7e88a94818f748917ec472ab4e4919cab095b0b11615a7a9304b25b514a95f962b0920c1da8e6c64f498a5fd5a8675fd3ca308c1e98f65bc8
|
data/README.md
CHANGED
@@ -9,7 +9,9 @@
|
|
9
9
|
|
10
10
|
*"So simple its almost magic" (Amazed developer)*
|
11
11
|
|
12
|
-
#### NOTE: reactive-record >= 0.8.x depends on the reactrb gem. You must [upgrade to reactrb](https://github.com/reactrb/reactrb#upgrading-to-reactrb)
|
12
|
+
#### NOTE: reactive-record >= 0.8.x depends on the reactrb gem. You must [upgrade to reactrb](https://github.com/reactrb/reactrb#upgrading-to-reactrb)
|
13
|
+
|
14
|
+
#### NOTE: therubyracer has been removed as a dependency to allow the possibility of using other JS runtimes. Please make sure if you're upgrading that you have it (or another runtime) required in your gemfile.
|
13
15
|
|
14
16
|
You do nothing to your current active-record models except move them to the models/public directory (so they are compiled on the client as well as the server.)
|
15
17
|
|
@@ -21,11 +23,11 @@ You do nothing to your current active-record models except move them to the mode
|
|
21
23
|
|
22
24
|
There are no docs yet, but you may consider the test cases as a starting point, or have a look at [reactrb todo](https://reactiverb-todo.herokuapp.com/) (live demo [here.](https://reactiverb-todo.herokuapp.com/))
|
23
25
|
|
24
|
-
For best results simply use the [reactrb-rails-
|
26
|
+
For best results simply use the [reactrb-rails-generator](https://github.com/reactrb/reactrb-rails-generator) to install everything you need into a new or existing rails app.
|
25
27
|
|
26
28
|
Head on over to [gitter.im](https://gitter.im/reactrb/chat) to ask any questions you might have!
|
27
29
|
|
28
|
-
Note: We have dropped suppport for the ability to load the same Class from two different files. If you need this functionality load the following code to your config/application.rb file.
|
30
|
+
Note: We have dropped suppport for the ability to have rails load the same Class *automatically* from two different files, one with server side code, and one with client side code. If you need this functionality load the following code to your config/application.rb file. However we found from experience that this was very confusing, and you are better off to explicitly include modules as needed.
|
29
31
|
|
30
32
|
```ruby
|
31
33
|
module ::ActiveRecord
|
@@ -48,3 +50,12 @@ module ::ActiveRecord
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
```
|
53
|
+
|
54
|
+
## Running tests
|
55
|
+
The test suite runs in opal on a rails server, so the test database is actually the test_app's dev database.
|
56
|
+
|
57
|
+
* ```cd spec/test_app```
|
58
|
+
* ```rake db:reset``` (to prepare the "test" database)
|
59
|
+
* ```rails s```
|
60
|
+
* visit localhost:3000/spec-opal to run the suite.
|
61
|
+
Note: If any tests fail when running the entire suite, there is a good possibility that you will need to run ```rake db:reset``` to fix the database before running the tests again.
|
@@ -82,6 +82,16 @@ module ActiveRecord
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
def load(*attributes, &block)
|
86
|
+
first_time = true
|
87
|
+
ReactiveRecord.load do
|
88
|
+
results = attributes.collect { |attr| @backing_record.reactive_get!(attr, first_time) }
|
89
|
+
results = yield *results if block
|
90
|
+
first_time = false
|
91
|
+
block.nil? && results.count == 1 ? results.first : results
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
85
95
|
def save(opts = {}, &block)
|
86
96
|
@backing_record.save(opts.has_key?(:validate) ? opts[:validate] : true, opts[:force], &block)
|
87
97
|
end
|
@@ -133,7 +133,7 @@ module ReactiveRecord
|
|
133
133
|
@dummy_collection.notify
|
134
134
|
array = new_array.is_a?(Collection) ? new_array.collection : new_array
|
135
135
|
@collection.each_with_index do |r, i|
|
136
|
-
r.id = new_array[i].id if array[i] and array[i].id and r.backing_record.vector.last =~ /^\*[0-9]+$/
|
136
|
+
r.id = new_array[i].id if array[i] and array[i].id and !r.new? and r.backing_record.vector.last =~ /^\*[0-9]+$/
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactive-record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch VanDuyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -67,13 +67,13 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: therubyracer
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: opal-
|
84
|
+
name: opal-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: opal-browser
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: react-rails
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|