Module: Trinidad::Helpers

Included in:
Extensions::Extension, Extensions::Extension
Defined in:
lib/trinidad/helpers.rb

Constant Summary collapse

@@silence =

:nodoc

nil
@@deprecated =

:nodoc

{}

Class Method Summary collapse

Class Method Details

.camelize(string) ⇒ Object



26
27
28
29
30
31
# File 'lib/trinidad/helpers.rb', line 26

def camelize(string)
  string = string.to_s.sub(/^[a-z\d]*/) { $&.capitalize }
  string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{$2.capitalize}" }
  string.gsub!('/', '::')
  string
end

.deprecate(msg, prefix = '[DEPRECATED] ') ⇒ Object

Print a deprecated message (once - no matter how many times it’s called).



20
21
22
23
24
# File 'lib/trinidad/helpers.rb', line 20

def deprecate(msg, prefix = '[DEPRECATED] ')
  return nil if @@deprecated[msg]
  @@deprecated[msg] = true
  Helpers.warn "#{prefix}#{msg}" # Kernel.warn
end

.silence!Object

Silence ! (… or I kill you)



8
# File 'lib/trinidad/helpers.rb', line 8

def self.silence!; @@silence = true; end

.silence?Boolean

Should we be silent - no warnings will be printed.

Returns:

  • (Boolean)


6
# File 'lib/trinidad/helpers.rb', line 6

def self.silence?; @@silence; end

.warn(msg) ⇒ Object

Print a warning (Kernel.warn).



11
12
13
# File 'lib/trinidad/helpers.rb', line 11

def self.warn(msg)
  super unless silence? # Kernel.warn
end