mongoid_money_field 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9872f92a8e94961a24bfdc1555fec6dd83708eca
4
- data.tar.gz: db2c1d912130b1f54bfbe4832c22a313f6515d4a
3
+ metadata.gz: e9afcb21a7fea8313402923450b0232818783799
4
+ data.tar.gz: f615c0755fabe9b7a2cb456aea9fe0a696575250
5
5
  SHA512:
6
- metadata.gz: 9b8205c61b1aa83a20809933df9cb4cf0dfe2976c922b7c85b47cf5d145d3abdc96e8ad5ea3eb4acd4cad15579a95f7f3c0e2bb7155f2bd5291aa1faf2458c94
7
- data.tar.gz: bfdc740e907c52fe3aa3179124c06bdcd049eddd3ae801ede55c4bd64a41c38525b10c613c0777df85690df859e39dcb9a1dd64897403b7b65e7dadb15c6e953
6
+ metadata.gz: 009cf0e74b18f28afdc8db6d405d2b4007b1c13ce8fb1c161b1bf8b8658e2b24c1e8dac4e3223653502249e2afd401e0e4561a7836d05a08cede08ffafbe528d
7
+ data.tar.gz: 711d61c738369b2b0f8c530987cb5c5fcdbdcd3ae12b5874fa311b38629949070ebdef89b1019f68492788c2430cade661e220c665218978b84701ff6558fd6c
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- mongoid_money_field (5.0.0)
15
+ mongoid_money_field (5.0.1)
16
16
  money (>= 5.0.0)
17
17
  mongoid (>= 3.0.0)
18
18
 
@@ -36,8 +36,8 @@ GEM
36
36
  i18n (0.6.5)
37
37
  json (1.8.1)
38
38
  minitest (4.7.5)
39
- money (5.1.1)
40
- i18n (~> 0.6.0)
39
+ money (6.0.0)
40
+ i18n (~> 0.6.4)
41
41
  mongoid-rspec (1.7.0)
42
42
  mongoid (>= 3.0.1)
43
43
  rake
@@ -0,0 +1,42 @@
1
+ require 'rails_admin/adapters/mongoid'
2
+ require 'rails_admin/config/fields/types/string'
3
+ module RailsAdmin
4
+ module Adapters
5
+ module Mongoid
6
+ alias_method :type_lookup_without_money, :type_lookup
7
+ def type_lookup(name, field)
8
+ if field.type.to_s == 'Money' || field.type.class.name == 'MoneyType'
9
+ { :type => :money_field }
10
+ else
11
+ type_lookup_without_money(name, field)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ module Config
18
+ module Fields
19
+ module Types
20
+ class MoneyField < RailsAdmin::Config::Fields::Types::String
21
+ # Register field type for the type loader
22
+ RailsAdmin::Config::Fields::Types::register(self)
23
+
24
+ register_instance_option :pretty_value do
25
+ ret = if value.class.name == 'Hash' && value['cents']
26
+ "%.2f" % ::Money.new(value['cents'], value['currency_iso']).to_f
27
+ elsif value.respond_to?(:cents)
28
+ "%.2f" % value.to_f
29
+ else
30
+ value
31
+ end
32
+ end
33
+
34
+ register_instance_option :formatted_value do
35
+ pretty_value
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
@@ -1,3 +1,3 @@
1
1
  module MongoidMoneyField
2
- VERSION = "5.0.0"
2
+ VERSION = "5.0.1"
3
3
  end
@@ -28,4 +28,8 @@ end
28
28
 
29
29
  if Object.const_defined?("SimpleForm")
30
30
  require "mongoid_money_field/simple_form/money_input"
31
+ end
32
+
33
+ if Object.const_defined?("RailsAdmin")
34
+ require "mongoid_money_field/rails_admin"
31
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_money_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Tv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-06 00:00:00.000000000 Z
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -160,6 +160,7 @@ files:
160
160
  - gemfiles/money6-mongoid4.gemfile
161
161
  - lib/mongoid_money_field.rb
162
162
  - lib/mongoid_money_field/field.rb
163
+ - lib/mongoid_money_field/rails_admin.rb
163
164
  - lib/mongoid_money_field/simple_form/money_input.rb
164
165
  - lib/mongoid_money_field/type.rb
165
166
  - lib/mongoid_money_field/version.rb