class Cattri::Context
def define_method(attribute, name: nil, &block)
-
(void)
-
Raises:
-
(Cattri::AttributeError)
- if method is already defined and not forced
Other tags:
- Yield: - method implementation block
Parameters:
-
name
(Symbol, nil
) -- optional method name override -
attribute
(Cattri::Attribute
) --
def define_method(attribute, name: nil, &block) name = (name || attribute.name).to_sym target = target_for(attribute) if method_defined?(attribute, name: name) raise Cattri::AttributeError, "Method `:#{name}` already defined on #{target}" end define_method!(target, attribute, name, &block) end