Completed
Pull Request — master (#14)
by Marcelo
40s
created

Time.coerce_not_nil()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
1
require 'time'
2
3
module Koine
4
  module Attributes
5
    module Adapter
6
      class Time < Base
7
        private
8
9
        def coerce_not_nil(value)
10
          secure do
11
            next value if value.is_a?(::Time)
12
            ::Time.parse(value)
13
          rescue StandardError => error
0 ignored issues
show
Bug introduced by
The Ruby parser could not interpret the code. It reported: unexpected token kRESCUE (Using Ruby 2.0 ...meter, under `AllCops`).
Loading history...
14
            raise ArgumentError, error
15
          end
16
        end
17
      end
18
    end
19
  end
20
end
21