georgepalmer-couch_foo 0.7.14 → 0.7.15

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.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/couch_foo/base.rb +11 -2
  3. metadata +2 -2
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 7
4
- :patch: 14
4
+ :patch: 15
@@ -1825,8 +1825,7 @@ module CouchFoo
1825
1825
  # attributes not included in that won't be allowed to be mass-assigned.
1826
1826
  def attributes=(new_attributes, guard_protected_attributes = true)
1827
1827
  return if new_attributes.nil?
1828
- attributes = new_attributes.dup
1829
- attributes.stringify_keys!
1828
+ attributes = normalize_attrs(new_attributes)
1830
1829
 
1831
1830
  multi_parameter_attributes = []
1832
1831
  attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes
@@ -1974,6 +1973,16 @@ module CouchFoo
1974
1973
  write_attribute(self.class.inheritance_column, self.class.name)
1975
1974
  end
1976
1975
  end
1976
+
1977
+ def normalize_attrs(new_attributes)
1978
+ attributes = new_attributes.dup
1979
+ attributes.stringify_keys!
1980
+ id = attributes.delete("id")
1981
+ rev = attributes.delete("rev")
1982
+ attributes["_id"] = id if id
1983
+ attributes["_rev"] = rev if rev
1984
+ attributes
1985
+ end
1977
1986
 
1978
1987
  def remove_attributes_protected_from_mass_assignment(attributes)
1979
1988
  safe_attributes =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: georgepalmer-couch_foo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.14
4
+ version: 0.7.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Palmer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-02 00:00:00 -08:00
12
+ date: 2009-03-04 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency