Sha256: f8dd7da9e832d368c6ef7efeb7e837cce7aae3ba6a14a34a84a4559fb323cf64
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
require 'yard-dm/extensions' module YARD module DM class HasHandler < YARD::Handlers::Ruby::Base include Extensions handles method_call(:has) def process args = statement.parameters n = args[0] name = args[1].last return unless name.type == :symbol return unless ( (n.type == :int && n.source =~ /^[1-9]\d*$/) || (n.type == :var_ref && n.source == 'n') || (n.type == :dot2 && ( (n[0].type == :int && n[0].source =~ /^[0-9]\d*$/) || ( (n[1].type == :int && n[1].source =~ /^[1-9]\d*$/) || (n[1].type == :var_ref && n[1].source == 'n') ) )) ) nobj = effected_namespace mscope = scope name = name.source[1..-1] register MethodObject.new(nobj, name, :class) do |o| o.visibility = :public o.source = statement.source o.signature = "def self.#{name}" o.parameters = [['repository', 'nil']] end register MethodObject.new(nobj, name, mscope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}" end register MethodObject.new(nobj, "#{name}=", mscope) do |o| o.visibility = :public o.source = statement.source o.signature = "def #{name}=" o.parameters = [["new_#{name}", nil]] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yard-dm-0.1.1 | lib/yard-dm/has_handler.rb |
yard-dm-0.1.0 | lib/yard-dm/has_handler.rb |