ginjo-rfm 3.0.10 → 3.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzE0NWI5NTNjMDVhM2M0ZjZjMzI2Y2FiNDcyOGRiZmIxMGFlMmRiZQ==
4
+ M2MxNTI1ZTEyNTc4NjNkYzQ3OTFlNDNlZTVjODFkN2FlNTBiZWUyNw==
5
5
  data.tar.gz: !binary |-
6
- MDY0MjgyNjJlYjM5NjBhNmVkYzFiN2NiMjI1ZWI3N2MzNzJiMDIxYQ==
6
+ OGRkNjViNjkxNjQ5NWMzNWI3OGI3MzE4ZjQ2Zjk4MTYwZDU2N2ZmYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTcxNTk2YWQ2NzMwYjJmZDEwZWJmNjA3Nzc2MDIxNTBlMTc2OTY1ZjhkYmQx
10
- MmU5ZjA3ZGU1MDY0NTY3NDlkNDA5YTc5MTNjNDNjZTdhZWY4NGQ2NmRmOTY1
11
- OTMxNzkwZWVhZjkzZDhjOGViNGYyYjYzZDRmMTc3NzQyNmU2OTM=
9
+ MjM5ZGE5ODFjNmY0NDdhNzYxMDNhOTBjY2VlMDdkMTZhMGFkMDJiMWU2ZTVl
10
+ OWQzNmRiMDM5MjMzY2RhZjI2MTVkZWNiMTlkNjIyZWMzNTVjZmY5Y2QxODMx
11
+ NWRhZjI0OTQyYzhhODI5MzMzNmY3MjIyODI4NmU1NzM2ZjI3ODI=
12
12
  data.tar.gz: !binary |-
13
- MjY3MTNmYjBkNGU4YTE4ZTQ0MzA4YWU1NGQxYzY0NDdlZGIxOTQ2MGM4MGE2
14
- Yjc2NTVlNDFhMjc5MzU4NDE3MGRlMjQ3NjFhMmY0Yzg1NjkwN2Q0YmJhMzky
15
- YWEwZDg3ZTNhYzUwOWU2YWFkYTAwMWY4YTYxMmNjMTI5OTQwZDA=
13
+ MGEyMzYxYmM2MjYyN2MyMjdmNzMxZmQzZDEzMDNiNjRhNzhiNTM0NjE0ZDMz
14
+ YjMyNDFkMTBhMTVmNWVhM2U4ZmIzMWZmZDZhODFjYjA3ZjVhMTYzMWJiNjlm
15
+ NTFhN2M3NjAwZjI4NGJmMjc4ZGZhNmUzNDQyOTViNjZiZmZkYTA=
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## Ginjo-Rfm 3.0.11
4
+
5
+ * Scoping fixes, changes, additions:
6
+
7
+ Now takes proc or array of hashes or hash.
8
+
9
+ Scope_args for scope proc now defaults to model instance.
10
+
11
+ Now handles omits - puts them at end of request array.
12
+
13
+ * Support for rom-fmp 0.0.4 - query chaining with compound fm queries.
14
+
15
+ * Basic support for portal field writes.
16
+
17
+ record['my_relationship::my_field.0'] = 'Adds a new portal record with data for my_field, if auto-create enabled'
18
+ record.update_attributes! 'my_relationship::my_field.3' => 'Updates my_field in 3rd portal record, if exists'
19
+
20
+ * Fix Base#save! to store raised exceptions in errors, if possible.
21
+
22
+ * Fix CompoundQuery to handle nil values in query params.
23
+
3
24
  ## Ginjo-Rfm 3.0.10
4
25
 
5
26
  * Fixed bug where missing metadata would cause errors when creating/editing records.
@@ -1 +1 @@
1
- 3.0.10
1
+ 3.0.11
@@ -151,7 +151,7 @@ module Rfm
151
151
  def update_attributes(new_attr)
152
152
  new_attr.each do |k,v|
153
153
  k = k.to_s.downcase
154
- if keys.include?(k)
154
+ if key?(k) || (layout.field_keys.include?(k.split('.')[0]) rescue nil)
155
155
  @mods[k] = v
156
156
  self[k] = v
157
157
  else
@@ -201,14 +201,19 @@ module Rfm
201
201
  else
202
202
  self.create
203
203
  end
204
+ rescue
205
+ (self.errors[:base] rescue []) << $!
206
+ raise $!
204
207
  end
205
208
 
206
209
  # Same as save!, but will not raise error.
207
210
  def save
208
211
  save!
212
+ # rescue
213
+ # (self.errors[:base] rescue []) << $!
214
+ # return nil
209
215
  rescue
210
- (self.errors[:base] rescue []) << $!
211
- return nil
216
+ nil
212
217
  end
213
218
 
214
219
  # Just like Layout#save_if_not_modified, but with callbacks & validations.
@@ -209,8 +209,11 @@ module Rfm
209
209
 
210
210
  def []=(key, val)
211
211
  key_string = key.to_s.downcase
212
- return super unless @loaded # is this needed?
213
- raise Rfm::ParameterError, "You attempted to modify a field (#{key_string}) that does not exist in the current Filemaker layout." unless self.key?(key_string)
212
+ key_string_base = key_string.split('.')[0]
213
+ return super unless @loaded # is this needed? yes, for loading fresh records.
214
+ unless self.key?(key_string) || (layout.field_keys.include?(key_string_base) rescue nil)
215
+ raise Rfm::ParameterError, "You attempted to modify a field (#{key_string}) that does not exist in the current Filemaker layout."
216
+ end
214
217
  # @mods[key_string] = val
215
218
  # TODO: This needs cleaning up.
216
219
  # TODO: can we get field_type from record instead?
@@ -75,6 +75,7 @@ module Rfm
75
75
  input_hash.each do |key,val|
76
76
  query_tag = []
77
77
  val = val.rfm_force_array
78
+ val << nil if val.empty?
78
79
  val.each do |v|
79
80
  @key_values["-q#{key_counter}"] = field_mapping[key] || key
80
81
  @key_values["-q#{key_counter}.value"] = v
@@ -17,27 +17,40 @@ module Rfm
17
17
  # instead of above scope constant.
18
18
 
19
19
  def find(*args)
20
- new_args = apply_scope(*args)
20
+ new_args = apply_scope(args)
21
21
  super(*new_args)
22
22
  end
23
23
 
24
24
  def count(*args)
25
- new_args = apply_scope(*args)
25
+ new_args = apply_scope(args)
26
26
  super(*new_args)
27
27
  end
28
28
 
29
- # Mix scope requests with user requests (sorta like a cross-join of requests).
30
- def apply_scope(*args)
29
+ # Mix scope requests with user requests with a constraining AND logic.
30
+ # Also handles request options.
31
+ def apply_scope(args, input_scope=nil)
32
+ #puts "APPLY_SCOPE args:#{args} input_scope:#{input_scope}"
31
33
  opts = (args.size > 1 && args.last.is_a?(Hash) ? args.pop : {})
32
- scope = [opts.delete(:scope) || self::SCOPE.call(opts.delete(:scope_args))].flatten
34
+ scope_args = opts.delete(:scope_args) || self
35
+ raw_scope = input_scope || opts.delete(:scope) || self::SCOPE
36
+ scope = [raw_scope.is_a?(Proc) ? raw_scope.call(scope_args) : raw_scope].flatten.compact
37
+ #puts "APPLY_SCOPE scope:#{scope}"
38
+
33
39
  return [args].flatten(1).push(opts) if !(args[0].is_a?(Array) || args[0].is_a?(Hash)) || scope.size < 1
34
40
  scoped_requests = []
41
+ scope_omits = []
35
42
  scope.each do |scope_req|
43
+ if scope_req[:omit]
44
+ scope_omits.push scope_req
45
+ next
46
+ end
36
47
  [args].flatten.each do |req|
37
48
  scoped_requests.push(req[:omit] ? req : req.merge(scope_req))
38
49
  end
39
50
  end
40
- scoped_query = [scoped_requests, opts]
51
+ scoped_requests = [args].flatten if scoped_requests.empty?
52
+ scoped_query = [scoped_requests | scope_omits, opts]
53
+ #puts "APPLY SCOPE output:#{scoped_query}"
41
54
  scoped_query
42
55
  end
43
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ginjo-rfm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.10
4
+ version: 3.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Richardson
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-09-10 00:00:00.000000000 Z
15
+ date: 2015-09-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activemodel