mongoid_money_field 3.2.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +0 -0
- data/.gitignore +18 -0
- data/.rspec +0 -0
- data/.travis.yml +8 -11
- data/Gemfile +3 -12
- data/Gemfile.lock +43 -38
- data/{MIT-LICENSE.txt → LICENSE.txt} +3 -1
- data/README.rdoc +15 -2
- data/Rakefile +4 -39
- data/gemfiles/{mongoid3.gemfile → money4-mongoid3.gemfile} +1 -1
- data/gemfiles/money4-mongoid31.gemfile +12 -0
- data/gemfiles/{mongoid2.gemfile → money50-mongoid3.gemfile} +10 -10
- data/gemfiles/money50-mongoid31.gemfile +12 -0
- data/gemfiles/money51-mongoid3.gemfile +11 -0
- data/gemfiles/money51-mongoid31.gemfile +12 -0
- data/lib/mongoid_money_field.rb +118 -76
- data/lib/mongoid_money_field/field.rb +48 -0
- data/lib/mongoid_money_field/simple_form/money_input.rb +1 -1
- data/lib/mongoid_money_field/version.rb +3 -0
- data/mongoid_money_field.gemspec +26 -83
- data/spec/model_spec.rb +8 -0
- data/spec/money3_compat_spec.rb +123 -0
- data/spec/money3_spec.rb +342 -0
- data/spec/money_spec.rb +60 -46
- data/spec/ruby_money_spec.rb +62 -0
- data/spec/spec_helper.rb +15 -16
- data/spec/support/dummy_not_a_number.rb +0 -0
- data/spec/support/dummy_positive_number.rb +0 -0
- data/spec/support/money3.rb +30 -0
- data/spec/support/mongoid.yml +8 -0
- data/spec/support/priceable.rb +5 -0
- metadata +90 -37
- data/VERSION +0 -1
data/.document
CHANGED
File without changes
|
data/.gitignore
ADDED
data/.rspec
CHANGED
File without changes
|
data/.travis.yml
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
services: mongodb
|
3
3
|
gemfile:
|
4
|
-
|
5
|
-
|
4
|
+
#- gemfiles/money4-mongoid3.gemfile
|
5
|
+
#- gemfiles/money4-mongoid31.gemfile
|
6
|
+
- gemfiles/money50-mongoid3.gemfile
|
7
|
+
#- gemfiles/money50-mongoid31.gemfile
|
8
|
+
- gemfiles/money51-mongoid3.gemfile
|
9
|
+
- gemfiles/money51-mongoid31.gemfile
|
6
10
|
rvm:
|
7
|
-
- 1.9.2
|
8
11
|
- 1.9.3
|
9
|
-
|
10
|
-
|
11
|
-
matrix:
|
12
|
-
exclude:
|
13
|
-
- rvm: 1.9.2
|
14
|
-
gemfile: gemfiles/mongoid3.gemfile
|
15
|
-
- rvm: rbx-19mode
|
16
|
-
gemfile: gemfiles/mongoid2.gemfile
|
12
|
+
#- rbx-19mode
|
13
|
+
#- jruby-19mode
|
data/Gemfile
CHANGED
@@ -1,13 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem "rspec", "~> 2.12.0"
|
8
|
-
gem "rdoc", "~> 3.12"
|
9
|
-
gem "bundler", ">= 1.1.0"
|
10
|
-
gem "jeweler", "~> 1.8.3"
|
11
|
-
gem "simplecov", '>= 0.4.0', :require => false
|
12
|
-
gem "database_cleaner", "~> 0.9.0"
|
13
|
-
end
|
3
|
+
# Specify your gem's dependencies in mongoid_money_field.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,59 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mongoid_money_field (4.0.0)
|
5
|
+
money
|
6
|
+
mongoid (>= 3.0.0)
|
7
|
+
|
1
8
|
GEM
|
2
|
-
remote:
|
9
|
+
remote: https://rubygems.org/
|
3
10
|
specs:
|
4
|
-
activemodel (3.2.
|
5
|
-
activesupport (= 3.2.
|
11
|
+
activemodel (3.2.13)
|
12
|
+
activesupport (= 3.2.13)
|
6
13
|
builder (~> 3.0.0)
|
7
|
-
activesupport (3.2.
|
8
|
-
i18n (
|
14
|
+
activesupport (3.2.13)
|
15
|
+
i18n (= 0.6.1)
|
9
16
|
multi_json (~> 1.0)
|
10
17
|
builder (3.0.4)
|
11
18
|
database_cleaner (0.9.1)
|
12
|
-
diff-lcs (1.1
|
13
|
-
git (1.2.5)
|
19
|
+
diff-lcs (1.2.1)
|
14
20
|
i18n (0.6.1)
|
15
|
-
|
16
|
-
|
17
|
-
git (>= 1.2.5)
|
18
|
-
rake
|
19
|
-
rdoc
|
20
|
-
json (1.7.5)
|
21
|
-
money (5.1.0)
|
21
|
+
json (1.7.7)
|
22
|
+
money (5.1.1)
|
22
23
|
i18n (~> 0.6.0)
|
23
|
-
mongoid (3.
|
24
|
-
activemodel (~> 3.
|
25
|
-
moped (~> 1.
|
24
|
+
mongoid (3.1.2)
|
25
|
+
activemodel (~> 3.2)
|
26
|
+
moped (~> 1.4.2)
|
26
27
|
origin (~> 1.0)
|
27
28
|
tzinfo (~> 0.3.22)
|
28
|
-
|
29
|
-
|
29
|
+
mongoid-rspec (1.7.0)
|
30
|
+
mongoid (>= 3.0.1)
|
31
|
+
rake
|
32
|
+
rspec (>= 2.9)
|
33
|
+
moped (1.4.5)
|
34
|
+
multi_json (1.7.2)
|
30
35
|
origin (1.0.11)
|
31
|
-
rake (10.0.
|
32
|
-
rdoc (
|
36
|
+
rake (10.0.4)
|
37
|
+
rdoc (4.0.1)
|
33
38
|
json (~> 1.4)
|
34
|
-
rspec (2.
|
35
|
-
rspec-core (~> 2.
|
36
|
-
rspec-expectations (~> 2.
|
37
|
-
rspec-mocks (~> 2.
|
38
|
-
rspec-core (2.
|
39
|
-
rspec-expectations (2.
|
40
|
-
diff-lcs (
|
41
|
-
rspec-mocks (2.
|
39
|
+
rspec (2.13.0)
|
40
|
+
rspec-core (~> 2.13.0)
|
41
|
+
rspec-expectations (~> 2.13.0)
|
42
|
+
rspec-mocks (~> 2.13.0)
|
43
|
+
rspec-core (2.13.1)
|
44
|
+
rspec-expectations (2.13.0)
|
45
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
46
|
+
rspec-mocks (2.13.0)
|
42
47
|
simplecov (0.7.1)
|
43
48
|
multi_json (~> 1.0)
|
44
49
|
simplecov-html (~> 0.7.1)
|
45
50
|
simplecov-html (0.7.1)
|
46
|
-
tzinfo (0.3.
|
51
|
+
tzinfo (0.3.37)
|
47
52
|
|
48
53
|
PLATFORMS
|
49
54
|
ruby
|
50
55
|
|
51
56
|
DEPENDENCIES
|
52
|
-
bundler (
|
53
|
-
database_cleaner (~> 0.9.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
rdoc (~>
|
58
|
-
rspec (~> 2.
|
59
|
-
simplecov (
|
57
|
+
bundler (~> 1.3.4)
|
58
|
+
database_cleaner (~> 0.9.1)
|
59
|
+
mongoid-rspec (~> 1.7.0)
|
60
|
+
mongoid_money_field!
|
61
|
+
rake
|
62
|
+
rdoc (~> 4.0.1)
|
63
|
+
rspec (~> 2.13.0)
|
64
|
+
simplecov (~> 0.7.1)
|
data/README.rdoc
CHANGED
@@ -15,8 +15,21 @@ A simple gem that creates a Money datatype using RubyMoney for Mongoid.
|
|
15
15
|
|
16
16
|
Inspired by https://gist.github.com/840500
|
17
17
|
|
18
|
+
== Alternatives
|
19
|
+
|
20
|
+
https://github.com/RubyMoney/money-rails
|
21
|
+
|
22
|
+
With v4 storage format of mongoid money field is identical to that of money-rails
|
23
|
+
|
18
24
|
== Updating
|
19
|
-
|
25
|
+
|
26
|
+
v4 is a massive refactor. Storage format is now a hash, like money-rails, instead of two separate cents and currency fields
|
27
|
+
Old values should be still accessible after you update. To migrate to new storage format do:
|
28
|
+
|
29
|
+
YourModel.migrate_from_money_field_3!(your_money_fields)
|
30
|
+
|
31
|
+
|
32
|
+
v3 has a minor break of backwards compatibility in favour of having syntax and defaults similar to field mongoid macro
|
20
33
|
|
21
34
|
To get the same behaviour as 1.0 please add "default: 0" to field declaration, like this
|
22
35
|
|
@@ -72,5 +85,5 @@ DummyMoney.where(price_cents: 123).first
|
|
72
85
|
|
73
86
|
== Copyright
|
74
87
|
|
75
|
-
Copyright (c) 2012 glebtv. MIT License.
|
88
|
+
Copyright (c) 2012-2013 glebtv (http://rocketscience.pro). MIT License.
|
76
89
|
|
data/Rakefile
CHANGED
@@ -1,44 +1,9 @@
|
|
1
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "mongoid_money_field"
|
18
|
-
gem.homepage = "http://github.com/glebtv/mongoid_money_field"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Use RubyMoney with mongoid}
|
21
|
-
gem.description = %Q{Use RubyMoney with mongoid}
|
22
|
-
gem.email = "glebtv@gmail.com"
|
23
|
-
gem.authors = ["glebtv"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core'
|
29
3
|
require 'rspec/core/rake_task'
|
30
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
-
end
|
33
4
|
|
5
|
+
desc 'Default: run specs.'
|
34
6
|
task :default => :spec
|
35
7
|
|
36
|
-
|
37
|
-
|
38
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
-
|
40
|
-
rdoc.rdoc_dir = 'rdoc'
|
41
|
-
rdoc.title = "mongoid_money_field #{version}"
|
42
|
-
rdoc.rdoc_files.include('README*')
|
43
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
-
end
|
8
|
+
desc "Run specs"
|
9
|
+
RSpec::Core::RakeTask.new
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'mongoid', '~> 3.1.0'
|
4
|
+
gem "money", "~> 4.0.2"
|
5
|
+
|
6
|
+
gem "rake"
|
7
|
+
gem "bundler", "~> 1.3.4"
|
8
|
+
gem "rspec", "~> 2.13.0"
|
9
|
+
gem "rdoc", "~> 4.0.1"
|
10
|
+
gem "simplecov", "~> 0.7.1", require: false
|
11
|
+
gem "database_cleaner", "~> 0.9.1"
|
12
|
+
gem "mongoid-rspec", "~> 1.7.0"
|
@@ -1,11 +1,11 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
gem 'mongoid', '~>
|
4
|
-
gem
|
5
|
-
|
6
|
-
gem "rspec", "~> 2.12.0"
|
7
|
-
gem "rdoc", "~> 3.12"
|
8
|
-
gem "bundler", ">= 1.1.0"
|
9
|
-
gem "jeweler", "~> 1.8.3"
|
10
|
-
gem "simplecov", '>= 0.4.0', :require => false
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'mongoid', '~> 3.0.0'
|
4
|
+
gem "money", "~> 5.0.0"
|
5
|
+
|
6
|
+
gem "rspec", "~> 2.12.0"
|
7
|
+
gem "rdoc", "~> 3.12"
|
8
|
+
gem "bundler", ">= 1.1.0"
|
9
|
+
gem "jeweler", "~> 1.8.3"
|
10
|
+
gem "simplecov", '>= 0.4.0', :require => false
|
11
11
|
gem "database_cleaner", "~> 0.9.0"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'mongoid', '~> 3.1.0'
|
4
|
+
gem "money", "~> 5.0.0"
|
5
|
+
|
6
|
+
gem "rake"
|
7
|
+
gem "bundler", "~> 1.3.4"
|
8
|
+
gem "rspec", "~> 2.13.0"
|
9
|
+
gem "rdoc", "~> 4.0.1"
|
10
|
+
gem "simplecov", "~> 0.7.1", require: false
|
11
|
+
gem "database_cleaner", "~> 0.9.1"
|
12
|
+
gem "mongoid-rspec", "~> 1.7.0"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'mongoid', '~> 3.0.0'
|
4
|
+
gem "money", "~> 5.1.1"
|
5
|
+
|
6
|
+
gem "rspec", "~> 2.12.0"
|
7
|
+
gem "rdoc", "~> 3.12"
|
8
|
+
gem "bundler", ">= 1.1.0"
|
9
|
+
gem "jeweler", "~> 1.8.3"
|
10
|
+
gem "simplecov", '>= 0.4.0', :require => false
|
11
|
+
gem "database_cleaner", "~> 0.9.0"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'mongoid', '~> 3.1.0'
|
4
|
+
gem "money", "~> 5.1.1"
|
5
|
+
|
6
|
+
gem "rake"
|
7
|
+
gem "bundler", "~> 1.3.4"
|
8
|
+
gem "rspec", "~> 2.13.0"
|
9
|
+
gem "rdoc", "~> 4.0.1"
|
10
|
+
gem "simplecov", "~> 0.7.1", require: false
|
11
|
+
gem "database_cleaner", "~> 0.9.1"
|
12
|
+
gem "mongoid-rspec", "~> 1.7.0"
|
data/lib/mongoid_money_field.rb
CHANGED
@@ -1,119 +1,161 @@
|
|
1
1
|
#encoding: utf-8
|
2
2
|
|
3
|
-
require
|
3
|
+
require "money"
|
4
|
+
require "mongoid_money_field/version"
|
5
|
+
require "mongoid_money_field/field"
|
4
6
|
|
5
7
|
module Mongoid
|
6
8
|
module MoneyField
|
7
9
|
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
included do
|
10
|
-
end
|
11
10
|
|
12
11
|
module ClassMethods
|
13
|
-
|
14
|
-
def money_field( *columns )
|
12
|
+
def money_field(*columns)
|
15
13
|
opts = columns.last.is_a?( Hash ) ? columns.pop : {}
|
16
14
|
opts = {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
fixed_currency: nil,
|
16
|
+
default: nil,
|
17
|
+
required: false,
|
18
|
+
default_currency: nil
|
21
19
|
}.merge( opts )
|
22
20
|
|
23
|
-
|
24
|
-
|
21
|
+
ensure_default = Proc.new do |currency|
|
22
|
+
if opts[:fixed_currency].nil?
|
23
|
+
if currency.nil?
|
24
|
+
if opts[:default_currency].nil?
|
25
|
+
Money.default_currency
|
26
|
+
else
|
27
|
+
opts[:default_currency]
|
28
|
+
end
|
29
|
+
else
|
30
|
+
currency
|
31
|
+
end
|
32
|
+
else
|
33
|
+
opts[:fixed_currency]
|
34
|
+
end
|
35
|
+
end
|
25
36
|
|
37
|
+
[columns].flatten.each do |name|
|
38
|
+
default = nil
|
26
39
|
name = name.to_s
|
27
|
-
|
28
40
|
unless opts[:default].nil?
|
29
|
-
default = Money.parse(
|
30
|
-
default_cents = default.cents
|
41
|
+
default = Money.parse(opts[:default])
|
31
42
|
end
|
32
43
|
|
33
|
-
|
34
|
-
|
35
|
-
attr_plain = name + '_plain'
|
36
|
-
attr_before_type_cast = name + '_before_type_cast'
|
37
|
-
|
38
|
-
field attr_cents, type: Integer, default: default_cents
|
44
|
+
field name, type: Money, default: default
|
45
|
+
validates_presence_of name if opts[:required]
|
39
46
|
|
40
|
-
|
47
|
+
define_method("#{name}=") do |value|
|
48
|
+
instance_variable_set( "@#{name}_before_type_cast".to_sym, value)
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
if opts[:fixed_currency].nil?
|
47
|
-
default_currency = nil
|
48
|
-
|
49
|
-
if opts[:default_currency].nil?
|
50
|
-
default_currency = default.currency.iso_code unless default.nil?
|
50
|
+
if value.blank?
|
51
|
+
write_attribute(name, nil)
|
51
52
|
else
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
if opts[:default_currency].nil?
|
54
|
+
money = value.to_money
|
55
|
+
else
|
56
|
+
old_default = Money.default_currency
|
57
|
+
Money.default_currency = Money::Currency.new(opts[:default_currency])
|
58
|
+
money = value.to_money
|
59
|
+
Money.default_currency = old_default
|
60
|
+
end
|
56
61
|
|
57
|
-
|
58
|
-
|
59
|
-
self[ attr_currency ] ||= Money.default_currency.iso_code
|
62
|
+
unless opts[:fixed_currency].nil?
|
63
|
+
money = Money.new(money.cents, opts[:fixed_currency])
|
60
64
|
end
|
65
|
+
|
66
|
+
write_attribute(name, money)
|
67
|
+
remove_attribute("#{name}_currency")
|
68
|
+
remove_attribute("#{name}_cents")
|
61
69
|
end
|
62
70
|
end
|
63
71
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
72
|
+
# mongoid money field 2 compat
|
73
|
+
define_method(name) do
|
74
|
+
if read_attribute("#{name}_cents").nil?
|
75
|
+
value = read_attribute(name)
|
76
|
+
if value.nil?
|
77
|
+
nil
|
78
|
+
else
|
79
|
+
if value.is_a?(Hash)
|
80
|
+
value[:currency_iso] = ensure_default.call(value[:currency_iso])
|
81
|
+
end
|
82
|
+
Money.demongoize(value)
|
83
|
+
end
|
71
84
|
|
72
|
-
|
85
|
+
else
|
86
|
+
currency = read_attribute("#{name}_currency")
|
87
|
+
currency = ensure_default.call(currency)
|
88
|
+
Money.new(read_attribute("#{name}_cents"), currency)
|
89
|
+
end
|
73
90
|
end
|
74
91
|
|
75
|
-
define_method(
|
76
|
-
|
92
|
+
define_method("#{name}_before_type_cast") do
|
93
|
+
instance_variable_get( "@#{name}_before_type_cast".to_sym) || send(name).to_s
|
94
|
+
end
|
77
95
|
|
78
|
-
|
96
|
+
# deprecated
|
97
|
+
define_method("migrate_#{name}_from_money_3!") do
|
98
|
+
cents = read_attribute("#{name}_cents")
|
99
|
+
if cents.nil?
|
100
|
+
send("#{name}=", nil)
|
101
|
+
else
|
102
|
+
currency = read_attribute("#{name}_currency")
|
103
|
+
|
104
|
+
if currency.nil?
|
105
|
+
if opts[:default_currency].nil?
|
106
|
+
currency = Money.default_currency
|
107
|
+
else
|
108
|
+
currency = opts[:default_currency]
|
109
|
+
end
|
110
|
+
end
|
79
111
|
|
80
|
-
|
112
|
+
unless opts[:fixed_currency].nil?
|
113
|
+
currency = opts[:fixed_currency]
|
114
|
+
end
|
115
|
+
send("#{name}=", Money.new(cents, currency))
|
116
|
+
end
|
81
117
|
end
|
82
|
-
|
83
|
-
define_method( attr_plain ) do
|
84
|
-
value = instance_variable_get( "@#{attr_plain}".to_sym )
|
85
|
-
value = self.send( name ) if value.nil?
|
86
|
-
value = value.format( symbol: false, no_cents_if_whole: true, thousands_separator: false ) if value.is_a?( Money )
|
87
118
|
|
88
|
-
|
119
|
+
# deprecated
|
120
|
+
define_method("#{name}_cents") do
|
121
|
+
send(name).nil? ? 0 : send(name).cents
|
89
122
|
end
|
90
|
-
|
91
|
-
define_method( "#{attr_plain}=" ) do |value|
|
92
|
-
instance_variable_set( "@#{attr_plain}".to_sym, value )
|
93
123
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
124
|
+
# deprecated
|
125
|
+
define_method("#{name}_currency") do
|
126
|
+
if opts[:fixed_currency].nil?
|
127
|
+
send(name).nil? ? Money.default_currency : send(name).currency.iso_code
|
128
|
+
else
|
129
|
+
opts[:fixed_currency]
|
99
130
|
end
|
131
|
+
end
|
100
132
|
|
101
|
-
|
102
|
-
|
133
|
+
# deprecated
|
134
|
+
define_method("#{name}_cents=") do |val|
|
135
|
+
send("#{name}=", Money.new(val, send("#{name}_currency")))
|
136
|
+
end
|
103
137
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
Money.default_currency = old_default
|
109
|
-
end
|
138
|
+
# deprecated
|
139
|
+
define_method("#{name}_currency=") do |val|
|
140
|
+
send("#{name}=", Money.new(send("#{name}_cents"), val))
|
141
|
+
end
|
110
142
|
|
111
|
-
|
112
|
-
|
143
|
+
# deprecated
|
144
|
+
define_method("#{name}_plain=") do |val|
|
145
|
+
send("#{name}=", val)
|
146
|
+
end
|
147
|
+
# deprecated
|
148
|
+
define_method("#{name}_plain") do |val|
|
149
|
+
send("#{name}")
|
113
150
|
end
|
151
|
+
end
|
152
|
+
end
|
114
153
|
|
115
|
-
|
116
|
-
|
154
|
+
def migrate_from_money_field_3!(*columns)
|
155
|
+
each do |val|
|
156
|
+
[columns].flatten.each do |name|
|
157
|
+
val.send("migrate_#{name.to_s}_from_money_3!")
|
158
|
+
val.save!
|
117
159
|
end
|
118
160
|
end
|
119
161
|
end
|