hammock 0.5.2 → 0.5.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/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.5.3 2009-10-30
2
+ On AR::Base.find_or_create_with, only adjust when there are dirty attributes.
3
+
4
+
1
5
  == 0.5.2 2009-10-29
2
6
  Added Time#to_i_msec.
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
data/hammock.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hammock}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Hoskings"]
12
- s.date = %q{2009-10-29}
12
+ s.date = %q{2009-10-30}
13
13
  s.description = %q{}
14
14
  s.email = %q{ben@hoskings.net}
15
15
  s.extra_rdoc_files = [
data/lib/hammock.rb CHANGED
@@ -4,7 +4,7 @@ require 'ambition'
4
4
  require 'ambition/adapters/active_record'
5
5
 
6
6
  module Hammock
7
- VERSION = '0.5.2'
7
+ VERSION = '0.5.3'
8
8
  IncludeTarget = ActionController::Base
9
9
 
10
10
  def self.included base # :nodoc:
@@ -92,10 +92,10 @@ module Hammock
92
92
  end
93
93
  end
94
94
 
95
- def find_or_create_with(find_attributes, create_attributes = {}, adjust_attributes = false)
95
+ def find_or_create_with(find_attributes, create_attributes = {}, should_adjust = false)
96
96
  if record = find_or_new_with(find_attributes, create_attributes)
97
97
  log "Create failed. #{record.errors.inspect}", :skip => 1 if record.new_record? && !record.save
98
- log "Adjust failed. #{record.errors.inspect}", :skip => 1 if adjust_attributes && !record.update_attributes(create_attributes)
98
+ log "Adjust failed. #{record.errors.inspect}", :skip => 1 if should_adjust && !record.adjust_attributes(create_attributes)
99
99
  record
100
100
  end
101
101
  end
@@ -194,6 +194,11 @@ module Hammock
194
194
  }
195
195
  end
196
196
 
197
+ def adjust_attributes attrs
198
+ attributes = attrs
199
+ changed.empty? || update_attributes(attrs)
200
+ end
201
+
197
202
  # Offset +attribute+ by +offset+ atomically in SQL.
198
203
  def offset! attribute, offset
199
204
  if new_record?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hoskings
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-29 00:00:00 +11:00
12
+ date: 2009-10-30 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency