mm-multi-parameter-attributes 0.2.0 → 0.2.1

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/Rakefile CHANGED
@@ -15,7 +15,7 @@ spec = Gem::Specification.new do |s|
15
15
 
16
16
  # Change these as appropriate
17
17
  s.name = "mm-multi-parameter-attributes"
18
- s.version = "0.2.0"
18
+ s.version = "0.2.1"
19
19
  s.summary = "Tiny plugin for MongoMapper to add multi-parameter attributes"
20
20
  s.author = "Richard Livsey"
21
21
  s.email = "richard@livsey.org"
@@ -44,18 +44,20 @@ module MongoMapper
44
44
  values = values_with_empty_parameters.reject(&:nil?)
45
45
 
46
46
  if !values.reject{|x| x.blank? }.empty?
47
+ values = values.map(&:to_i)
48
+
47
49
  key = self.class.keys[name]
48
50
  raise ArgumentError, "Unknown key #{name}" if key.nil?
49
51
  klass = key.type
50
52
 
51
53
  value = if Time == klass
52
- Time.zone.local(*values.map(&:to_i))
54
+ Time.zone.local(*values)
53
55
  elsif Date == klass
54
56
  begin
55
57
  values = values_with_empty_parameters.map{|v| v.blank? ? 1 : v.to_i}
56
58
  Date.new(*values)
57
59
  rescue ArgumentError => ex # if Date.new raises an exception on an invalid date
58
- Time.zone.local(*values.map(&:to_i)).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
60
+ Time.zone.local(*values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
59
61
  end
60
62
  else
61
63
  klass.new(*values)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mm-multi-parameter-attributes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Richard Livsey