File: mattr_accessor_handler.rb

package info (click to toggle)
ruby-view-component 2.74.1-1
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm
  • size: 3,156 kB
  • sloc: ruby: 6,731; sh: 163; javascript: 10; makefile: 4
file content (19 lines) | stat: -rw-r--r-- 529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module YARD
  # YARD Handler to parse `mattr_accessor` calls.
  class MattrAccessorHandler < YARD::Handlers::Ruby::Base
    handles method_call(:mattr_accessor)
    namespace_only

    process do
      name = statement.parameters.first.jump(:tstring_content, :ident).source
      object = YARD::CodeObjects::MethodObject.new(namespace, name)
      register(object)
      parse_block(statement.last, owner: object)

      object.dynamic = true
      object[:mattr_accessor] = true
    end
  end
end