Sha256: 5e244aae343d3aba7fdff81ffca6275e35e8a5ac5299c9aefdd2adec8e681577
Contents?: true
Size: 514 Bytes
Versions: 19
Compression:
Stored size: 514 Bytes
Contents
module Acfs::Model::Attributes class Base attr_reader :options def initialize(opts = {}) @options = opts @options.reverse_merge! allow_nil: true end def nil_allowed? !!options[:allow_nil] end def default_value options[:default].is_a?(Proc) ? options[:default] : cast(options[:default]) end def cast(obj) return nil if obj.nil? && nil_allowed? cast_type obj end def cast_type(obj) raise NotImplementedError end end end
Version data entries
19 entries across 19 versions & 1 rubygems