Sha256: 19c185bf7b699b4620b61af826c2dab095a6bd58905cf2a46b982cbd2f30f91f

Contents?: true

Size: 429 Bytes

Versions: 17

Compression:

Stored size: 429 Bytes

Contents

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

17 entries across 17 versions & 1 rubygems

Version Path
acfs-1.3.2 lib/acfs/resource/attributes/base.rb
acfs-1.3.1 lib/acfs/resource/attributes/base.rb
acfs-1.3.0 lib/acfs/resource/attributes/base.rb
acfs-1.2.1 lib/acfs/resource/attributes/base.rb
acfs-0.50.0 lib/acfs/resource/attributes/base.rb
acfs-1.2.0 lib/acfs/resource/attributes/base.rb
acfs-0.49.1 lib/acfs/resource/attributes/base.rb
acfs-1.1.1 lib/acfs/resource/attributes/base.rb
acfs-0.49.0 lib/acfs/resource/attributes/base.rb
acfs-1.1.0 lib/acfs/resource/attributes/base.rb
acfs-0.48.2 lib/acfs/resource/attributes/base.rb
acfs-1.0.1 lib/acfs/resource/attributes/base.rb
acfs-0.48.1 lib/acfs/resource/attributes/base.rb
acfs-1.0.0 lib/acfs/resource/attributes/base.rb
acfs-0.48.0 lib/acfs/resource/attributes/base.rb
acfs-0.47.0 lib/acfs/resource/attributes/base.rb
acfs-0.46.0 lib/acfs/resource/attributes/base.rb