pottery 0.1.2 → 0.1.3
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 +2 -0
- data/lib/pottery.rb +9 -9
- data/pottery.gemspec +1 -1
- metadata +1 -1
data/CHANGELOG
CHANGED
data/lib/pottery.rb
CHANGED
@@ -2,7 +2,7 @@ require 'morph'
|
|
2
2
|
require 'soup'
|
3
3
|
|
4
4
|
module Pottery
|
5
|
-
VERSION = "0.1.
|
5
|
+
VERSION = "0.1.3"
|
6
6
|
|
7
7
|
def self.included(base)
|
8
8
|
Soup.prepare
|
@@ -18,16 +18,16 @@ module Pottery
|
|
18
18
|
|
19
19
|
module ClassMethods
|
20
20
|
def restore name
|
21
|
-
|
22
|
-
if
|
23
|
-
if
|
24
|
-
last =
|
21
|
+
existing = Soup[name]
|
22
|
+
if existing && !(existing.is_a?(Array) && existing.empty?)
|
23
|
+
if existing.is_a? Array
|
24
|
+
last = existing.pop
|
25
25
|
puts 'deleting duplicates for id: ' + name
|
26
|
-
|
27
|
-
|
26
|
+
existing.each {|x| x.destroy}
|
27
|
+
existing = last
|
28
28
|
end
|
29
29
|
instance = self.new
|
30
|
-
attributes =
|
30
|
+
attributes = existing.attributes
|
31
31
|
unless attributes.empty?
|
32
32
|
id_name = attributes.delete('name')
|
33
33
|
name = attributes.delete('name_name')
|
@@ -47,7 +47,7 @@ module Pottery
|
|
47
47
|
def save
|
48
48
|
if respond_to?('id_name') && !id_name.nil? && !(id_name.to_s.strip.size == 0)
|
49
49
|
existing = Soup[id_name]
|
50
|
-
if existing && existing
|
50
|
+
if existing && !(existing.is_a?(Array) && existing.empty?)
|
51
51
|
if existing.is_a? Array
|
52
52
|
last = existing.pop
|
53
53
|
puts 'deleting duplicates for id: ' + id_name
|
data/pottery.gemspec
CHANGED