Sha256: df2a52a1722b248d7e24b517d45412d999bc1ee910496d31c800fc824533ad29

Contents?: true

Size: 456 Bytes

Versions: 7

Compression:

Stored size: 456 Bytes

Contents

# frozen_string_literal: true

module Acfs::Resource::Attributes
  class Base
    attr_reader :default

    def initialize(default: nil)
      @default = default
    end

    def cast(value)
      cast_value(value) unless value.nil?
    end

    def default_value
      if default.respond_to? :call
        default
      else
        cast default
      end
    end

    private

    def cast_value(_value)
      raise NotImplementedError
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acfs-2.0.0 lib/acfs/resource/attributes/base.rb
acfs-1.7.0 lib/acfs/resource/attributes/base.rb
acfs-1.6.0 lib/acfs/resource/attributes/base.rb
acfs-1.5.1 lib/acfs/resource/attributes/base.rb
acfs-1.5.0 lib/acfs/resource/attributes/base.rb
acfs-1.4.0 lib/acfs/resource/attributes/base.rb
acfs-1.3.4 lib/acfs/resource/attributes/base.rb