Module: AutoCamelize

Defined in:
lib/docu_sign/extensions.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



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

def method_missing(method_name, *args, &block)
  ds_name = ds_equivalent(method_name)

  if ds_name && respond_to?(ds_name)
    self.class.class_eval %Q{
      def #{method_name}(*args, &block)
        send "#{ds_name}", *args, &block
      end
    }

    send method_name, *args, &block
  else
    super
  end
end

Instance Method Details

#ds_equivalent(string) ⇒ Object

Find the equivalent built-in method name, if there is one. Example: ds_equivalent(‘pdf_bytes’) => ‘pDFBytes’



59
60
61
62
# File 'lib/docu_sign/extensions.rb', line 59

def ds_equivalent(string)
  string = string.to_s.camelize(:lower)
  methods.find { |m| m.downcase == string.downcase }
end