aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/value.rb
blob: 54a3e9dd7afa78dd8c4b61403a5bf937ea3c1d2f (plain) (blame)
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
40
41
42
43
44
45
46
47
48
module ActiveRecord
  module ConnectionAdapters
    module Type
      class Value # :nodoc:
        attr_reader :precision, :scale, :limit

        def initialize(options = {})
          options.assert_valid_keys(:precision, :scale, :limit)
          @precision = options[:precision]
          @scale = options[:scale]
          @limit = options[:limit]
        end

        def type; end

        def type_cast(value)
          cast_value(value) unless value.nil?
        end

        def type_cast_for_write(value)
          value
        end

        def text?
          false
        end

        def number?
          false
        end

        def binary?
          false
        end

        def klass
          ::Object
        end

        private

        def cast_value(value)
          value
        end
      end
    end
  end
end