Sha256: a1045207e679016f8bea610831b9daf8d4cfc5cb95756223db9dc1d7dc8841c1
Contents?: true
Size: 550 Bytes
Versions: 1
Compression:
Stored size: 550 Bytes
Contents
module Ciesta class Field DEFAULT_TYPE = Ciesta::Types::Any attr_accessor :name, :type def initialize(name, options) self.name = name.to_sym self.type = options.delete(:type) || DEFAULT_TYPE self.value = options.delete(:default) end def value current_value end def value=(val) self.current_value = type[val] rescue Dry::Types::ConstraintError raise ViolatesConstraints, "#{current_value} is not a #{type.name}" end private attr_accessor :current_value end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ciesta-0.1.1 | lib/ciesta/field.rb |