Method: Filigree::TypedClass::ClassMethods#typed_ivar

Defined in:
lib/filigree/types.rb

#typed_ivar(name, type, nillable: false, strict: false) ⇒ void

This method returns an undefined value.

Define a typed instance variable.

Parameters:

  • name (Symbol)

    Name of the accessor

  • type (Class)

    Type of the accessor

  • nillable (Boolean) (defaults to: false)

    If the value can be nil or not

  • strict (Boolean) (defaults to: false)

    To use strict checking or not



141
142
143
144
145
146
147
148
# File 'lib/filigree/types.rb', line 141

def typed_ivar(name, type, nillable: false, strict: false)
	typed_ivars << name

	define_typed_accessor(name, nillable, strict, *
		type.is_a?(Array) ? [type.first, method(:check_array_type)] : [type, method(:check_type)])

	attr_reader name
end