module T::Props::ClassMethods
def const(name, cls_or_args, args={})
def const(name, cls_or_args, args={}) if (cls_or_args.is_a?(Hash) && cls_or_args.key?(:immutable)) || args.key?(:immutable) Kernel.raise ArgumentError.new("Cannot pass 'immutable' argument when using 'const' keyword to define a prop") end if cls_or_args.is_a?(Hash) self.prop(name, cls_or_args.merge(immutable: true)) else self.prop(name, cls_or_args, args.merge(immutable: true)) end end
def decorator; @decorator ||= decorator_class.new(self); end
def decorator; @decorator ||= decorator_class.new(self); end
def decorator_class; Decorator; end
def decorator_class; Decorator; end
def extended(child)
def extended(child) decorator.model_inherited(child.singleton_class) super end
def included(child)
def included(child) decorator.model_inherited(child) super end
def inherited(child)
def inherited(child) decorator.model_inherited(child) super end
def plugin(mod)
def plugin(mod) decorator.plugin(mod) end
def plugins; @plugins ||= []; end
def plugins; @plugins ||= []; end
def prepended(child)
def prepended(child) decorator.model_inherited(child) super end
def prop(name, cls, rules={})
-
(void)-
Options Hash:
(**rules)-
:redaction(Symbol, Array) -- A redaction directive that may -
:override(T::Boolean) -- It is an error to redeclare a -
:immutable(T::Boolean) -- If true, this prop cannot be -
:factory(Proc) -- A `Proc` that will be called to -
:default(Object) -- A default value that will be set -
:foreign(Model, Symbol, Proc) -- A model class that this -
:ifunset(Object) -- A value to be returned if this -
:dont_store(T::Boolean) -- If true, this property will -
:enum(Array) -- An array of legal values; The -
:optional(T::Boolean, Symbol) -- If `true`, this property
Parameters:
-
rules(Hash) -- Options to control this property's behavior. -
cls(Class, T::Types::Base) -- The type of this -
name(Symbol) -- The name of this property
def prop(name, cls, rules={}) cls = T::Utils.coerce(cls) if !cls.is_a?(Module) decorator.prop_defined(name, cls, rules) end
def props; decorator.props; end
def props; decorator.props; end
def reload_decorator!; @decorator = decorator_class.new(self); end
def reload_decorator!; @decorator = decorator_class.new(self); end
def validate_prop_value(prop, val)
-
(void)-
Parameters:
-
val(Object) -- -
prop(Symbol) --
def validate_prop_value(prop, val) decorator.validate_prop_value(prop, val) end