Module: Fsck

Included in:
Object
Defined in:
lib/fsck.rb,
lib/fsck/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fsck.rb', line 2

def method_missing(sym, *args, &block)
  @_fsck_method_name_cache ||= {}
  
  return send(@_fsck_method_name_cache[sym], *args, &block) if @_fsck_method_name_cache[sym]
  
  fscked_method = sym.to_s
  
  if punctuation = fscked_method[/[!?=]$/]
    fscked_method.chop!
  end
  
  matches = methods.select do |m|
    fscked_method =~ /^#{__fsck_method_regex_str__(m)}#{punctuation}$/
  end

  if matches.empty?
    super
  else
    @_fsck_method_name_cache[sym] = matches.sort_by(&:length).last
    send(@_fsck_method_name_cache[sym], *args, &block)
  end
end