class Cattri::AttributeCompiler

def define_accessor!(attribute, context)

Returns:
  • (void) -

Parameters:
  • context (Cattri::Context) --
  • attribute (Cattri::Attribute) --
def define_accessor!(attribute, context)
  context.define_method(attribute) do |*args, **kwargs|
    readonly_call = args.empty? && kwargs.empty?
    return AttributeCompiler.send(:memoize_default_value, self, attribute) if readonly_call
    attribute.validate_assignment!
    value = attribute.process_assignment(*args, **kwargs)
    cattri_variable_set(attribute.ivar, value) # steep:ignore
  end
end