Sha256: 527d7f69f42ae1db5e232883d88b7e0c70a531e9464b58664d7662efccd3b1d1

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 Bytes

Contents

require 'yard/parser/ruby/ast_node'

module YARD
  module Rails
    class ClassAttributeHandler < YARD::Handlers::Ruby::AttributeHandler
      handles method_call(:cattr_accessor)
      handles method_call(:cattr_reader)
      handles method_call(:cattr_writer)
      handles method_call(:mattr_accessor)
      handles method_call(:mattr_reader)
      handles method_call(:mattr_writer)
      namespace_only
      
      def process
        # HACK: Strip the [c,m] off of the front of the method, so that
        # AttributeHandler will be able to correctly detect the resulting
        # method as read/write.
        name = statement[0].source[1..-1]
        statement[0] = YARD::Parser::Ruby::AstNode.node_class_for(:ident).new(:ident, [name])

        push_state(:scope => :class) { super }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yard-rails-0.3.0 lib/yard-rails/class_attribute_handler.rb
yard-rails-0.2.0 lib/yard-rails/class_attribute_handler.rb
yard-rails-0.1.0 lib/yard-rails/class_attribute_handler.rb