Module: Drudge::ClassDSL::ClassMethods

Defined in:
lib/drudge/class_dsl.rb

Instance Method Summary collapse

Instance Method Details

#__commandsObject



55
56
57
# File 'lib/drudge/class_dsl.rb', line 55

def __commands
  merged_commands((@__commands || []), (superclass.__commands rescue []))
end

#desc(description) ⇒ Object

When found before a method definition, it marks the Provides a short description for the next command



35
36
37
38
# File 'lib/drudge/class_dsl.rb', line 35

def desc(description)
  @__command_meta ||= {}
  @__command_meta[:desc] = description
end

#method_added(m) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/drudge/class_dsl.rb', line 40

def method_added(m)
  if @__command_meta and @__command_meta[:desc]
    meth = instance_method(m)

    @__commands ||= []
    @__commands << { name:   meth.name, 
                     params: parse_command_parameters(meth.parameters),
                     meta:   { desc: @__command_meta[:desc] } }

    @__command_meta = {}
  end

  super
end