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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a836715dff414352aca8fa4fbe91d987d4ac219d
4
- data.tar.gz: e7077d62b8071a21c0ea4289ccd3a7b9dd5e3938
3
+ metadata.gz: 32c824a576a794dbab1d8726018b1aae835d8d70
4
+ data.tar.gz: 15d0d3851ad5ed3bc6fc391b6b425c37d8e455cf
5
5
  SHA512:
6
- metadata.gz: ec0ca8663425dd46831d51cbb029897f51394c1432055d5f05f01063d2e7eb8fc5716e0111d664e6bab423998c3a70e9a3de4f0077bd3a230ca80b84351375c4
7
- data.tar.gz: 10819073b864f14caea7934d1e79b7f1d605b40a47b6bf6ee454f9c42fe555a8fe034c5d083f6bc4e7f2b3453b7bbaaaff789c6a464037c180c54ef9fb798508
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-installer](https://github.com/reactrb/reactrb-rails-installer) to install everything you need into a new or existing rails app.
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
 
@@ -181,6 +181,16 @@ module ReactiveRecord
181
181
  true
182
182
  end
183
183
 
184
+ def try(*args, &b)
185
+ if args.empty? && block_given?
186
+ yield self
187
+ else
188
+ send(*args, &b)
189
+ end
190
+ rescue
191
+ nil
192
+ end
193
+
184
194
  end
185
195
  end
186
196
 
@@ -1,3 +1,3 @@
1
1
  module ReactiveRecord
2
- VERSION = "0.8.1"
2
+ VERSION = "0.8.2"
3
3
  end
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.1
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-06-13 00:00:00.000000000 Z
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: opal-rails
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: :runtime
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-browser
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: react-rails
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: therubyracer
112
+ name: react-rails
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="