Sha256: c7fb69d217b55ce3ec6cd90361d6bcf2348225b84cc22dc204de0416db277f3b

Contents?: true

Size: 352 Bytes

Versions: 3

Compression:

Stored size: 352 Bytes

Contents

require_relative "base"

module RailsSettingsUi
  module ValueTypes
    class Duration < RailsSettingsUi::ValueTypes::Base
      def cast
        value.to_f.seconds
      end

      def validate
        unless value_numeric?
          self.errors << I18n.t("settings.errors.invalid_numeric", default: 'Invalid')
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-settings-ui-0.5.0 lib/rails-settings-ui/value_types/duration.rb
rails-settings-ui-0.4.0 lib/rails-settings-ui/value_types/duration.rb
rails-settings-ui-0.3.2 lib/rails-settings-ui/value_types/duration.rb