/
decimal128.rb
39 lines (33 loc) · 958 Bytes
/
decimal128.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true
# rubocop:todo all
module Mongoid
module Extensions
# Adds type-casting behavior to BSON::Decimal128 class.
module Decimal128
# Evolve the decimal128.
#
# @example Evolve the decimal128.
# decimal128.__evolve_decimal128__
#
# @return [ BSON::Decimal128 ] self.
def __evolve_decimal128__
self
end
module ClassMethods
# Evolve the object into a mongo-friendly value to query with.
#
# @example Evolve the object.
# Decimal128.evolve(dec)
#
# @param [ Object ] object The object to evolve.
#
# @return [ BSON::Decimal128 ] The decimal128.
def evolve(object)
object.__evolve_decimal128__
end
end
end
end
end
BSON::Decimal128.__send__(:include, Mongoid::Extensions::Decimal128)
BSON::Decimal128.extend(Mongoid::Extensions::Decimal128::ClassMethods)