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

Date.coerce_not_nil()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
1
module Koine
2
  module Attributes
3
    module Adapter
4
      class Date < Base
5
        private
6
7
        def coerce_not_nil(date)
8
          secure do
9
            next date if date.is_a?(::Date)
10
            next date.to_date if date.is_a?(::Time)
11
            ::Date.parse(date)
12
          rescue => 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...
13
            raise ArgumentError.new(error)
14
          end
15
        end
16
      end
17
    end
18
  end
19
end
20