Module: Vigilem::Core::EventHandler::Utils

Included in:
Vigilem::Core::EventHandler, Vigilem::Core::EventHandler, ClassMethods
Defined in:
lib/vigilem/core/event_handler.rb

Instance Method Summary collapse

Instance Method Details

#on_format?(str) ⇒ TrueClass || FalseClass

does the string passed in start with ‘on_’

Parameters:

  • str (String)

Returns:

  • (TrueClass || FalseClass)


36
37
38
# File 'lib/vigilem/core/event_handler.rb', line 36

def on_format?(str)
  str.start_with?('on_')
end

#respond_to?(sym, include_all = false) ⇒ TrueClass || FalseClass

Parameters:

  • sym (Symbol)

Returns:

  • (TrueClass || FalseClass)


29
30
31
# File 'lib/vigilem/core/event_handler.rb', line 29

def respond_to?(sym, include_all=false)
  on_format?(sym.to_s) || super(sym, include_all)
end

#snakecase_class_name(namespace) ⇒ String

Parameters:

  • namespace (#to_s)

Returns:

  • (String)


22
23
24
# File 'lib/vigilem/core/event_handler.rb', line 22

def snakecase_class_name(namespace)
  namespace.to_s.split('::').last.snakecase
end

#type_from_on_format(on_name) ⇒ Symbol

converts a “on_String” => :String

Parameters:

  • on_name (String)

Returns:

  • (Symbol)


43
44
45
# File 'lib/vigilem/core/event_handler.rb', line 43

def type_from_on_format(on_name)
  on_name.split('on_', 2).last.to_sym
end