modularity-rails 0.24.1 → 0.25.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,7 +53,7 @@ class modularity.PersistenceManager
53
53
 
54
54
 
55
55
  # Creates the given object on the server.
56
- create: (obj, callback) ->
56
+ create: (obj, success_callback, error_callback) ->
57
57
  data = {}
58
58
  data[@model_name] = obj
59
59
 
@@ -64,22 +64,26 @@ class modularity.PersistenceManager
64
64
  success: (server_response) =>
65
65
  server_obj = server_response[@model_name]
66
66
  @server_data.add server_obj
67
- callback server_obj
67
+ success_callback server_obj
68
+ error: (xhr) =>
69
+ error_callback(xhr.responseText) if error_callback
68
70
 
69
71
 
70
72
  # Deletes the given object from the server.
71
- delete: (obj, callback) ->
73
+ delete: (obj, success_callback, error_callback) ->
72
74
  @client_data.remove obj
73
75
  @server_data.remove obj
74
76
  jQuery.ajax
75
77
  url: @entry_url(obj)
76
78
  type: 'DELETE'
77
79
  success: ->
78
- callback() if callback?
80
+ success_callback() if success_callback?
81
+ error: (xhr) ->
82
+ error_callback(xhr.responseText) if error_callback
79
83
 
80
84
 
81
85
  # Deletes the given objects from the server.
82
- delete_many: (object_ids, callback) ->
86
+ delete_many: (object_ids, success_callback, error_callback) ->
83
87
  @client_data.remove_many object_ids
84
88
  @server_data.remove_many object_ids
85
89
  jQuery.ajax
@@ -87,7 +91,9 @@ class modularity.PersistenceManager
87
91
  type: 'DELETE'
88
92
  data: {ids: object_ids}
89
93
  success: ->
90
- callback() if callback?
94
+ success_callback() if success_callback?
95
+ error: (xhr) ->
96
+ error_callback(xhr.responseText) if error_callback
91
97
 
92
98
 
93
99
  # Returns the url to access a single entry.
@@ -119,33 +125,35 @@ class modularity.PersistenceManager
119
125
 
120
126
 
121
127
  # Returns the entry with the given key.
122
- load: (key, callback) ->
128
+ load: (key, success_callback) ->
123
129
 
124
130
  # Try to load from cache.
125
- return callback(entry) if entry = @get_cached key
131
+ return success_callback(entry) if entry = @get_cached key
126
132
 
127
133
  # No data on client at all --> load data from server.
128
134
  @loader.get "#{@base_url}/#{key}", (server_entry) =>
129
135
  @server_data.add server_entry
130
136
  client_entry = modularity.clone_hash server_entry
131
137
  @client_data.add client_entry
132
- callback client_entry
138
+ success_callback client_entry
133
139
 
134
140
 
135
141
  # Loads all objects from the server.
136
142
  # Provides the given params as parameters to the GET request.
137
- load_all: (callback, params) ->
143
+ load_all: (params, success_callback, error_callback) ->
138
144
  jQuery.ajax
139
145
  url: @collection_url()
140
146
  cache: no
141
147
  data: params
142
148
  success: (data) =>
143
149
  @server_data.add_all data
144
- callback()
150
+ success_callback() if success_callback
151
+ error: (xhr) ->
152
+ error_callback(xhr.responseText) if error_callback
145
153
 
146
154
 
147
155
  # Loads all entries with the given ids.
148
- load_many: (ids, callback) ->
156
+ load_many: (ids, success_callback) ->
149
157
  missing_ids = []
150
158
  entries = []
151
159
  $.each ids, (pos, id) =>
@@ -156,7 +164,7 @@ class modularity.PersistenceManager
156
164
  missing_ids.push id
157
165
 
158
166
  if missing_ids.length == 0
159
- return callback(entries)
167
+ return success_callback(entries)
160
168
 
161
169
  alert "uncached entries found: #{missing_ids}"
162
170
 
@@ -164,26 +172,26 @@ class modularity.PersistenceManager
164
172
  # Saves the given object.
165
173
  # Does the right thing (create or update) dependent on
166
174
  # whether the object already has a key parameter.
167
- save: (obj, callback) ->
175
+ save: (obj, success_callback, error_callback) ->
168
176
  if obj[@key]?
169
- @update obj, callback
177
+ @update obj, success_callback, error_callback
170
178
  else
171
- @create obj, callback
179
+ @create obj, success_callback, error_callback
172
180
 
173
181
 
174
182
  # Updates the given object.
175
183
  #
176
184
  # The given object must exist on the server already,
177
185
  # and have a proper value in the key attribute.
178
- update: (obj, callback) ->
186
+ update: (obj, success_callback, error_callback) ->
179
187
 
180
188
  # Handle updating several objects.
181
- return @update_many(obj, callback) if $.type(obj) == 'array'
189
+ return @update_many(obj, success_callback, error_callback) if $.type(obj) == 'array'
182
190
 
183
191
  # Create a new hash, containing only the changed attributes between obj and it's replica in @server_data.
184
192
  diff_obj = modularity.object_diff @server_data.get(obj[@key]), obj
185
193
  if modularity.object_length(diff_obj) == 0
186
- callback obj if callback
194
+ success_callback obj if success_callback
187
195
  return
188
196
 
189
197
  # Send to server
@@ -198,13 +206,15 @@ class modularity.PersistenceManager
198
206
  @server_data.add server_obj
199
207
  client_obj = modularity.clone_hash server_obj
200
208
  @client_data.add client_obj
201
- callback client_obj if callback
209
+ success_callback client_obj if success_callback
210
+ error: (xhr) ->
211
+ error_callback(xhr.responseText) if error_callback
202
212
 
203
213
 
204
214
  # Bulk-updates the given objects.
205
215
  # All the existing objects must exist on the server already,
206
216
  # and have a value in the key attribute.
207
- update_many: (objects, callback) ->
217
+ update_many: (objects, success_callback, error_callback) ->
208
218
 
209
219
  # Find all objects that have been changed on the client.
210
220
  diff_objects = @changed_objects_columns objects
@@ -223,4 +233,6 @@ class modularity.PersistenceManager
223
233
  client_object = modularity.clone_hash server_object
224
234
  @client_data.add client_object
225
235
  client_object)
226
- callback(client_objects) if callback
236
+ success_callback(client_objects) if success_callback
237
+ error: (xhr) ->
238
+ error_callback(xhr.responseText) if error_callback
@@ -1,3 +1,3 @@
1
1
  module ModularityRails
2
- VERSION = '0.24.1'
2
+ VERSION = '0.25.0'
3
3
  end
metadata CHANGED
@@ -1,127 +1,144 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modularity-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.1
4
+ prerelease:
5
+ version: 0.25.0
5
6
  platform: ruby
6
7
  authors:
7
8
  - Kevin Goslar
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-25 00:00:00.000000000 Z
12
+ date: 2013-05-04 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
15
+ prerelease: false
16
+ version_requirements: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - ~>
18
19
  - !ruby/object:Gem::Version
19
20
  version: 3.2.13
21
+ none: false
20
22
  type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
+ name: rails
24
+ requirement: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ~>
25
27
  - !ruby/object:Gem::Version
26
28
  version: 3.2.13
29
+ none: false
27
30
  - !ruby/object:Gem::Dependency
31
+ prerelease: false
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ none: false
38
+ type: :runtime
28
39
  name: coffee-rails
29
40
  requirement: !ruby/object:Gem::Requirement
30
41
  requirements:
31
- - - '>='
42
+ - - ! '>='
32
43
  - !ruby/object:Gem::Version
33
44
  version: '0'
34
- type: :runtime
45
+ none: false
46
+ - !ruby/object:Gem::Dependency
35
47
  prerelease: false
36
48
  version_requirements: !ruby/object:Gem::Requirement
37
49
  requirements:
38
- - - '>='
50
+ - - ! '>='
39
51
  - !ruby/object:Gem::Version
40
52
  version: '0'
41
- - !ruby/object:Gem::Dependency
53
+ none: false
54
+ type: :runtime
42
55
  name: jquery-rails
43
56
  requirement: !ruby/object:Gem::Requirement
44
57
  requirements:
45
- - - '>='
58
+ - - ! '>='
46
59
  - !ruby/object:Gem::Version
47
60
  version: '0'
48
- type: :runtime
61
+ none: false
62
+ - !ruby/object:Gem::Dependency
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ! '>='
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
- - !ruby/object:Gem::Dependency
69
+ none: false
70
+ type: :development
56
71
  name: guard-livereload
57
72
  requirement: !ruby/object:Gem::Requirement
58
73
  requirements:
59
- - - '>='
74
+ - - ! '>='
60
75
  - !ruby/object:Gem::Version
61
76
  version: '0'
62
- type: :development
77
+ none: false
78
+ - !ruby/object:Gem::Dependency
63
79
  prerelease: false
64
80
  version_requirements: !ruby/object:Gem::Requirement
65
81
  requirements:
66
- - - '>='
82
+ - - ! '>='
67
83
  - !ruby/object:Gem::Version
68
84
  version: '0'
69
- - !ruby/object:Gem::Dependency
85
+ none: false
86
+ type: :development
70
87
  name: konacha
71
88
  requirement: !ruby/object:Gem::Requirement
72
89
  requirements:
73
- - - '>='
90
+ - - ! '>='
74
91
  - !ruby/object:Gem::Version
75
92
  version: '0'
76
- type: :development
93
+ none: false
94
+ - !ruby/object:Gem::Dependency
77
95
  prerelease: false
78
96
  version_requirements: !ruby/object:Gem::Requirement
79
97
  requirements:
80
- - - '>='
98
+ - - ! '>='
81
99
  - !ruby/object:Gem::Version
82
100
  version: '0'
83
- - !ruby/object:Gem::Dependency
101
+ none: false
102
+ type: :development
84
103
  name: poltergeist
85
104
  requirement: !ruby/object:Gem::Requirement
86
105
  requirements:
87
- - - '>='
106
+ - - ! '>='
88
107
  - !ruby/object:Gem::Version
89
108
  version: '0'
90
- type: :development
109
+ none: false
110
+ - !ruby/object:Gem::Dependency
91
111
  prerelease: false
92
112
  version_requirements: !ruby/object:Gem::Requirement
93
113
  requirements:
94
- - - '>='
114
+ - - ! '>='
95
115
  - !ruby/object:Gem::Version
96
116
  version: '0'
97
- - !ruby/object:Gem::Dependency
117
+ none: false
118
+ type: :development
98
119
  name: rb-fsevent
99
120
  requirement: !ruby/object:Gem::Requirement
100
121
  requirements:
101
- - - '>='
122
+ - - ! '>='
102
123
  - !ruby/object:Gem::Version
103
124
  version: '0'
104
- type: :development
125
+ none: false
126
+ - !ruby/object:Gem::Dependency
105
127
  prerelease: false
106
128
  version_requirements: !ruby/object:Gem::Requirement
107
129
  requirements:
108
- - - '>='
130
+ - - ! '>='
109
131
  - !ruby/object:Gem::Version
110
132
  version: '0'
111
- - !ruby/object:Gem::Dependency
133
+ none: false
134
+ type: :development
112
135
  name: sqlite3
113
136
  requirement: !ruby/object:Gem::Requirement
114
137
  requirements:
115
- - - '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '>='
138
+ - - ! '>='
123
139
  - !ruby/object:Gem::Version
124
140
  version: '0'
141
+ none: false
125
142
  description: Makes the modularity-coffee framework available to Ruby on Rails applications.
126
143
  email:
127
144
  - kevin.goslar@gmail.com
@@ -150,26 +167,27 @@ files:
150
167
  - README.md
151
168
  homepage: http://github.com/kevgo/modularity-rails
152
169
  licenses: []
153
- metadata: {}
154
170
  post_install_message:
155
171
  rdoc_options: []
156
172
  require_paths:
157
173
  - lib
158
174
  required_ruby_version: !ruby/object:Gem::Requirement
159
175
  requirements:
160
- - - '>='
176
+ - - ! '>='
161
177
  - !ruby/object:Gem::Version
162
178
  version: '0'
179
+ none: false
163
180
  required_rubygems_version: !ruby/object:Gem::Requirement
164
181
  requirements:
165
- - - '>='
182
+ - - ! '>='
166
183
  - !ruby/object:Gem::Version
167
184
  version: '0'
185
+ none: false
168
186
  requirements: []
169
187
  rubyforge_project:
170
- rubygems_version: 2.0.3
188
+ rubygems_version: 1.8.25
171
189
  signing_key:
172
- specification_version: 4
190
+ specification_version: 3
173
191
  summary: A lightweight, object- and component-oriented CoffeeScript framework for
174
192
  Ruby on Rails applications.
175
193
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: dd888a27180051c8bba5993c08a25cc2e6f6a55c
4
- data.tar.gz: df788da5da1e37ba68e55a45691837f2a0b565ae
5
- SHA512:
6
- metadata.gz: c080193ca2960c75adabbedb08ed76308e44621bffae59b3d227a2906d97be90167a8a383ae5b059a72f32c6d1feda1dc013d9364d5c61440f11058c4b2d17eb
7
- data.tar.gz: a44d26c45c56acff547e188bfe207cbbcfb893db9a3b19ea8a4ef32e4e51dce9a301ebdf6dafe3c0d0a5ab81a866e12ce0b5ec6fd6289abf5f1789aea3235ffb