Class: Sys::Proc::Helper::Inflector

Inherits:
Object
  • Object
show all
Defined in:
lib/sys/proc/helper/inflector.rb

Instance Method Summary collapse

Constructor Details

#initializeInflector

Returns a new instance of Inflector.



12
13
14
15
16
# File 'lib/sys/proc/helper/inflector.rb', line 12

def initialize
  require 'active_support/inflector'

  @inflector = ActiveSupport::Inflector
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



28
29
30
31
32
33
34
# File 'lib/sys/proc/helper/inflector.rb', line 28

def method_missing(method, *args, &block)
  if respond_to_missing?(method)
    @inflector.public_send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#resolve(loadable) ⇒ Object

Load constant from a loadable/requirable path

Parameters:

  • loadable (String)

Returns:

  • (Object)


22
23
24
25
26
# File 'lib/sys/proc/helper/inflector.rb', line 22

def resolve(loadable)
  require loadable

  @inflector.constantize(@inflector.classify(loadable))
end

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

Returns:

  • (Boolean)


36
37
38
39
40
# File 'lib/sys/proc/helper/inflector.rb', line 36

def respond_to_missing?(method, include_private = false)
  return true if @inflector.respond_to?(method, include_private)

  super(method, include_private)
end