module YARD::Handlers::Ruby::StructHandlerMethods

def create_writer(klass, member)

Parameters:
  • member (String) -- the name of the member we're generating a method for
  • klass (ClassObject) -- the class to attach the method to
def create_writer(klass, member)
  # We want to convert these members into attributes just like
  # as if they were declared using attr_accessor.
  new_meth = register MethodObject.new(klass, "#{member}=", :instance) do |o|
    o.parameters = [['value', nil]]
    o.signature ||= "def #{member}=(value)"
    o.source ||= "#{o.signature}\n  @#{member} = value\nend"
  end
  add_writer_tags(klass, new_meth, member)
  klass.attributes[:instance][member][:write] = new_meth
end