persistize 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +2 -2
  2. data/lib/persistize.rb +22 -21
  3. metadata +3 -4
  4. data/VERSION +0 -1
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 = "persistize"
18
- s.version = "0.1.1"
18
+ s.version = "0.1.2"
19
19
  s.summary = "Easy denormalization for your ActiveRecord models"
20
20
  s.authors = ["Sergio Gil", "Luismi Cavallé"]
21
21
  s.email = "ballsbreaking@bebanjo.com"
@@ -26,7 +26,7 @@ spec = Gem::Specification.new do |s|
26
26
  s.rdoc_options = %w(--main README.rdoc)
27
27
 
28
28
  # Add any extra files to include in the gem
29
- s.files = %w(init.rb MIT-LICENSE persistize.gemspec Rakefile README.rdoc VERSION) + Dir.glob("{test,lib/**/*}")
29
+ s.files = %w(init.rb MIT-LICENSE persistize.gemspec Rakefile README.rdoc) + Dir.glob("{test,lib/**/*}")
30
30
  s.require_paths = ["lib"]
31
31
 
32
32
  # If you want to depend on other gems, add them here, along with any
data/lib/persistize.rb CHANGED
@@ -10,27 +10,28 @@ module Persistize
10
10
  update_method = :"_update_#{attribute}"
11
11
 
12
12
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
13
- alias #{original_method} #{method} # alias _unpersistized_full_name full_name
14
- #
15
- def #{method} # def full_name
16
- if new_record? || changed? # if new_record? || changed?
17
- #{original_method} # _unpersistized_full_name
18
- else # else
19
- self[:#{attribute}] # self[:full_name]
20
- end # end
21
- end # end
22
- #
23
- before_save :#{update_method}, :if => :changed? # before_save :_update_full_name
24
- #
25
- def #{update_method} # def _update_full_name
26
- self[:#{attribute}] = #{original_method} # self[:full_name] = _unpersistized_full_name
27
- true # return true to avoid canceling the save # true
28
- end # end
29
- #
30
- def #{update_method}! # def _update_full_name!
31
- #{update_method} # _update_full_name
32
- save! if #{attribute}_changed? # save! if full_name_changed?
33
- end # end
13
+ alias #{original_method} #{method} # alias _unpersistized_full_name full_name
14
+ #
15
+ def #{method} # def full_name
16
+ if new_record? || changed? # if new_record? || changed?
17
+ #{original_method} # _unpersistized_full_name
18
+ else # else
19
+ self[:#{attribute}] # self[:full_name]
20
+ end # end
21
+ end # end
22
+ #
23
+ before_save :#{update_method}, :if => :changed? # before_save :_update_full_name
24
+ #
25
+ def #{update_method} # def _update_full_name
26
+ self[:#{attribute}] = #{original_method} # self[:full_name] = _unpersistized_full_name
27
+ true # return true to avoid canceling the save # true
28
+ end # end
29
+ #
30
+ def #{update_method}! # def _update_full_name!
31
+ new_#{attribute} = #{original_method} # new_full_name = _unpersistized_full_name
32
+ return if new_#{attribute} == self[:#{attribute}] # return if new_full_name == self[:full_name]
33
+ update_attribute :#{attribute}, new_#{attribute} # update_attribute :full_name, new_full_name
34
+ end # end
34
35
  RUBY
35
36
 
36
37
  if options && options[:depending_on]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sergio Gil
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-30 00:00:00 +02:00
18
+ date: 2010-05-05 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -33,7 +33,6 @@ files:
33
33
  - persistize.gemspec
34
34
  - Rakefile
35
35
  - README.rdoc
36
- - VERSION
37
36
  - lib/persistize.rb
38
37
  has_rdoc: true
39
38
  homepage: http://githum.com/bebanjo/persistize
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0