ginjo-rfm 2.1.5 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## Ginjo-Rfm 2.1.6
4
+
5
+ * Fixed typo in Rfm::Record#[]=
6
+ * Fixed bug where valid? was called on models without ActiveModel::Validations being loaded.
7
+ * Fixed bug where Rfm::Base#reload wasn't clearing mods.
8
+
3
9
  ## Ginjo-Rfm 2.1.5
4
10
 
5
11
  * Fixed bug preventing validation callbacks from running.
data/lib/rfm/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.5
1
+ 2.1.6
data/lib/rfm/base.rb CHANGED
@@ -9,6 +9,7 @@ module Rfm
9
9
  # end
10
10
  #
11
11
  # And similar to ActiveRecord, you can define callbacks, validations, attributes, and methods on your model.
12
+ # (if you have ActiveModel loaded).
12
13
  #
13
14
  # class Account < Rfm::Base
14
15
  # config :layout=>'account_xml'
@@ -297,6 +298,7 @@ module Rfm
297
298
  # TODO: handle error when record has been deleted
298
299
  def reload(force=false)
299
300
  if (@mods.empty? or force) and record_id
301
+ @mods.clear
300
302
  self.replace self.class.find(self.record_id)
301
303
  end
302
304
  end
@@ -400,7 +402,7 @@ module Rfm
400
402
  end
401
403
 
402
404
  def create
403
- raise "Record not valid" unless valid?
405
+ raise "Record not valid" if (defined?(ActiveModel::Validations) && !valid?)
404
406
  run_callbacks :create do
405
407
  return unless @mods.size > 0
406
408
  merge_rfm_result self.class.create_from_new(@mods)
@@ -409,7 +411,7 @@ module Rfm
409
411
  end
410
412
 
411
413
  def update(mod_id=nil)
412
- raise "Record not valid" unless valid?
414
+ raise "Record not valid" if (defined?(ActiveModel::Validations) && !valid?)
413
415
  return false unless record_id
414
416
  run_callbacks :update do
415
417
  return unless @mods.size > 0
data/lib/rfm/record.rb CHANGED
@@ -222,24 +222,24 @@ module Rfm
222
222
  super
223
223
  end
224
224
 
225
- def []=(key, value)
225
+ def []=(key, val)
226
226
  key_string = key.to_s.downcase
227
227
  return super unless @loaded # is this needed?
228
228
  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)
229
- # @mods[key_string] = value
229
+ # @mods[key_string] = val
230
230
  # TODO: This needs cleaning up.
231
231
  # TODO: can we get field_type from record instead?
232
- @mods[key_string] = if [Date, Time, DateTime].member?(value.class)
232
+ @mods[key_string] = if [Date, Time, DateTime].member?(val.class)
233
233
  field_type = layout.field_meta[key_string.to_sym].result
234
234
  case field_type
235
235
  when 'time'; val.strftime(layout.time_format)
236
236
  when 'date'; val.strftime(layout.date_format)
237
237
  when 'timestamp'; val.strftime(layout.timestamp_format)
238
- else value
238
+ else val
239
239
  end
240
- else value
240
+ else val
241
241
  end
242
- super(key, value)
242
+ super(key, val)
243
243
  end
244
244
  #
245
245
  # alias_method :old_setter, '[]='
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: 2.1.5
4
+ version: 2.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-04-09 00:00:00.000000000 Z
16
+ date: 2013-04-16 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activesupport
@@ -265,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
265
265
  version: '0'
266
266
  segments:
267
267
  - 0
268
- hash: -1648802043392305173
268
+ hash: 802999713867049737
269
269
  required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  none: false
271
271
  requirements: