pottery 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +2 -0
  2. data/lib/pottery.rb +9 -9
  3. data/pottery.gemspec +1 -1
  4. metadata +1 -1
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.1.3. fixed bug in restoring saved object
2
+
1
3
  v0.1.2. ensure id_names are unique
2
4
 
3
5
  v0.1.1. updated to use Soup 0.2.1
@@ -2,7 +2,7 @@ require 'morph'
2
2
  require 'soup'
3
3
 
4
4
  module Pottery
5
- VERSION = "0.1.2"
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
- snip = Soup[name]
22
- if snip && snip != []
23
- if snip.is_a? Array
24
- last = snip.pop
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
- snip.each {|x| x.destroy}
27
- snip = last
26
+ existing.each {|x| x.destroy}
27
+ existing = last
28
28
  end
29
29
  instance = self.new
30
- attributes = snip.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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pottery}
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Rob McKinnon"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pottery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob McKinnon