class DomainModel::Field
Attributes
name[R]
types[R]
Public Class Methods
new(name, options = {})
click to toggle source
# File lib/domain_model.rb, line 169 def initialize(name, options = {}) @name = name @required = options.fetch(:required, false) @collection = options.fetch(:collection, false) @validate = options.fetch(:validate, false) raw_type = options.fetch(:type, Object) @types = raw_type.is_a?(Module) ? [raw_type] : raw_type if required? and collection? raise ArgumentError, "fields cannot be both :collection and :required" end end
Public Instance Methods
collection?()
click to toggle source
# File lib/domain_model.rb, line 195 def collection? !!@collection end
errors(value)
click to toggle source
# File lib/domain_model.rb, line 183 def errors(value) Validator.errors(self, value) end
monotype()
click to toggle source
# File lib/domain_model.rb, line 187 def monotype types.first if types.count == 1 end
required?()
click to toggle source
# File lib/domain_model.rb, line 191 def required? !!@required end
validate?()
click to toggle source
# File lib/domain_model.rb, line 199 def validate? !!@validate end