class Cattri::AttributeRegistry
def define_attribute(name, value, **options, &block)
-
(Cattri::AttributeError)
- if the name is already defined
Returns:
-
(Array
- list of methods defined by this attribute)
Other tags:
- Yield: - optional transformation block used as setter
Parameters:
-
options
(Hash
) -- attribute options (`:class`, `:final`, etc.) -
value
(Object, Proc, nil
) -- default value or initializer -
name
(String, Symbol
) -- the attribute name
def define_attribute(name, value, **options, &block) name = name.to_sym validate_unique!(name) options_with_default = options.merge(default: value) attribute = Cattri::Attribute.new( name, defined_in: context.target, **options_with_default, &block ) register_attribute(attribute) attribute.allowed_methods end