Method: Object#method_attr

Defined in:
lib/clean-annotations/method_attr.rb

#method_attr(name = nil, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/clean-annotations/method_attr.rb', line 35

def method_attr name=nil, &block
  if respond_to?(:const_missing) && respond_to?(:ancestors)
    if name.nil?
      return MethodAttributes.get(self) || {}
    end

    MethodAttributes.define self, name, &block
  else
    # instance
    base = MethodAttributes.get(self.class)
    name ? base[name] : base
  end
end