acts_as_money 0.2.5 → 0.2.6
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.
- checksums.yaml +7 -0
- data/lib/acts_as_money.rb +20 -24
- metadata +25 -26
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f0acd9111010707d5e6b956caf733e137b322c6905b88921bb0364a66b79f938
|
4
|
+
data.tar.gz: 47f022fc3f1c269022706d3b761566f34b374d0ea67cf381116ef605b250ad60
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3cbfb6969da13a1dc1364161017c5243bc6ffd1a8ea9e055a111bb2265568df4d99972fee5428941c59e4334659cdcc314216485a80c655533beb70876f0e606
|
7
|
+
data.tar.gz: 139d870ed0443eafd9ddca0874ad71afcf9d2e5342005f0b5746d47fd761620271cc6b8b47efcf638c95aacc94b333d217afea0f996d8724c67041584e1af6d2
|
data/lib/acts_as_money.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'money'
|
2
2
|
|
3
|
+
Money.locale_backend = :i18n
|
4
|
+
|
3
5
|
class ActiveRecord::Base
|
4
6
|
class << self
|
5
7
|
def acts_as_money
|
@@ -8,7 +10,6 @@ class ActiveRecord::Base
|
|
8
10
|
end
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
13
|
module ActsAsMoney #:nodoc:
|
13
14
|
def self.included(base) #:nodoc:
|
14
15
|
base.extend ClassMethods
|
@@ -17,29 +18,24 @@ module ActsAsMoney #:nodoc:
|
|
17
18
|
module ClassMethods
|
18
19
|
def money(name, options = {})
|
19
20
|
mapping = [[(options[:cents] || :cents).to_s, 'cents']]
|
20
|
-
mapping << [(options[:currency] || :currency).to_s, '
|
21
|
-
composed_of name,
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
}
|
21
|
+
mapping << [(options[:currency] || :currency).to_s, 'currency'] if options[:currency] != false
|
22
|
+
composed_of name,
|
23
|
+
class_name: 'Money',
|
24
|
+
allow_nil: options[:allow_nil],
|
25
|
+
mapping: mapping,
|
26
|
+
constructor: proc { |cents, currency| options[:allow_nil] && !cents ? nil : Money.new(cents || 0, currency || Money.default_currency) },
|
27
|
+
converter: proc { |value|
|
28
|
+
case value
|
29
|
+
when Integer
|
30
|
+
Money.new(value, Money.default_currency)
|
31
|
+
when Float
|
32
|
+
Money.new((value * 100).to_d, Money.default_currency)
|
33
|
+
when String
|
34
|
+
Money.new((value.to_f * 100).to_d, Money.default_currency)
|
35
|
+
else
|
36
|
+
value
|
37
|
+
end
|
38
|
+
}
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jordan Glasner
|
9
8
|
- Econsultancy
|
10
9
|
- Tim Cowlishaw
|
11
10
|
- Ylan Segal
|
11
|
+
- Michael Bennett
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: money
|
19
|
-
requirement:
|
20
|
-
none: false
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
21
20
|
requirements:
|
22
|
-
- -
|
21
|
+
- - ">="
|
23
22
|
- !ruby/object:Gem::Version
|
24
23
|
version: '0'
|
25
24
|
type: :runtime
|
26
25
|
prerelease: false
|
27
|
-
version_requirements:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
28
31
|
- !ruby/object:Gem::Dependency
|
29
32
|
name: activerecord
|
30
|
-
requirement:
|
31
|
-
none: false
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
32
34
|
requirements:
|
33
|
-
- -
|
35
|
+
- - ">="
|
34
36
|
- !ruby/object:Gem::Version
|
35
37
|
version: '0'
|
36
38
|
type: :runtime
|
37
39
|
prerelease: false
|
38
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
39
45
|
description:
|
40
|
-
email:
|
46
|
+
email: michael@michaelbennett.nyc
|
41
47
|
executables: []
|
42
48
|
extensions: []
|
43
49
|
extra_rdoc_files:
|
@@ -45,37 +51,30 @@ extra_rdoc_files:
|
|
45
51
|
files:
|
46
52
|
- README
|
47
53
|
- lib/acts_as_money.rb
|
48
|
-
homepage:
|
54
|
+
homepage: https://github.com/RecruitiFi/acts_as_money
|
49
55
|
licenses: []
|
56
|
+
metadata: {}
|
50
57
|
post_install_message:
|
51
58
|
rdoc_options:
|
52
|
-
- --main
|
59
|
+
- "--main"
|
53
60
|
- README
|
54
61
|
require_paths:
|
55
62
|
- lib
|
56
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
64
|
requirements:
|
59
|
-
- -
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0'
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
hash: 3980188286906307662
|
65
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
69
|
requirements:
|
68
|
-
- -
|
70
|
+
- - ">="
|
69
71
|
- !ruby/object:Gem::Version
|
70
72
|
version: '0'
|
71
|
-
segments:
|
72
|
-
- 0
|
73
|
-
hash: 3980188286906307662
|
74
73
|
requirements: []
|
75
74
|
rubyforge_project:
|
76
|
-
rubygems_version:
|
75
|
+
rubygems_version: 2.7.9
|
77
76
|
signing_key:
|
78
|
-
specification_version:
|
77
|
+
specification_version: 4
|
79
78
|
summary: A fairly trivial plugin allowing easy serialisation of Money values (from
|
80
79
|
the money gem) as attributes on activerecord objects
|
81
80
|
test_files: []
|