Module: NginxTail::Inflections

Defined in:
lib/ntail.rb

Class Method Summary collapse

Class Method Details

.component_to_module_name(component) ⇒ Object



7
8
9
10
# File 'lib/ntail.rb', line 7

def self.component_to_module_name(component)
  # this mimicks the ActiveSupport::Inflector.camelize() method in Rails...
  component.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end

.component_to_ntail_module(component) ⇒ Object



11
12
13
14
# File 'lib/ntail.rb', line 11

def self.component_to_ntail_module(component)
  # this mimicks the ActiveSupport::Inflector.constantize() method in Rails...
  NginxTail.const_get(self.component_to_module_name(component)) rescue nil
end