Sha256: 2dd052500f57097b7d608b42625f257cf7ec7faf15f74c5ae2a7e1c50c62c6a4

Contents?: true

Size: 385 Bytes

Versions: 12

Compression:

Stored size: 385 Bytes

Contents

module Datev
  class DateField < Field
    def format
      options[:format]
    end

    def validate!(value)
      super

      if value
        raise ArgumentError.new("Value given for field '#{name}' is not a Date or Time") unless value.is_a?(Time) || value.is_a?(Date)
      end
    end

    def output(value, _context=nil)
      value.strftime(format) if value
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
datev-0.11.0 lib/datev/field/date_field.rb
datev-0.10.0 lib/datev/field/date_field.rb
datev-0.9.0 lib/datev/field/date_field.rb
datev-0.8.2 lib/datev/field/date_field.rb
datev-0.8.1 lib/datev/field/date_field.rb
datev-0.8.0 lib/datev/field/date_field.rb
datev-0.7.0 lib/datev/field/date_field.rb
datev-0.6.0 lib/datev/field/date_field.rb
datev-0.5.1 lib/datev/field/date_field.rb
datev-0.5.0 lib/datev/field/date_field.rb
datev-0.4.0 lib/datev/field/date_field.rb
datev-0.3.1 lib/datev/field/date_field.rb