Module: MimiCheck::Extensions

Defined in:
lib/mimicheck/extensions.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mimicheck/extensions.rb', line 3

def method_missing(name, *args, &block)
  if (match = name.to_s.match(/(.+)Gen$/))
    gen_name = match[1]
    gen_class = MimiCheck::Generator.const_get(gen_name)

    self.class.send :define_method, name do |*argx|
      gen_class.new(*argx)
    end

    send(name, *args)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/mimicheck/extensions.rb', line 18

def respond_to_missing?(name, include_private = false)
  name.to_s.match(/(.+)Gen$/) || super
end