aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/value.rb
blob: 787b51dfa4801ffc252a391b3690b2daa0674d4e (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
module ActiveRecord
  module ConnectionAdapters
    module Type
      class Value # :nodoc:
        attr_reader :precision, :scale

        def initialize(options = {})
          options.assert_valid_keys(:precision, :scale)
          @precision = options[:precision]
          @scale = options[:scale]
        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