Method: SimpleCommand::KlassTransform#to_class_string

Defined in:
lib/simple_command_dispatcher/klass_transform.rb

#to_class_string(klass, options = {}) ⇒ String

Returns the klass as a string after transformations have been applied.

Examples:


to_class_string("MyClass") # => "MyClass"
to_class_string("myClass", { class_titleize: true }) # => "MyClass"
to_class_string(:MyClass) # => "MyClass"
to_class_string(:myClass, { class_titleize: true }) # => "MyClass"

Parameters:

  • klass (Symbol or String)

    the class name to be transformed.

  • options (Hash) (defaults to: {})

    the options that determine how klass will be transformed.

Options Hash (options):

  • :class_titleize (Boolean) — default: false

    Determines whether or not klass should be titleized.

Returns:

  • (String)

    the transformed class as a string.



141
142
143
144
145
146
# File 'lib/simple_command_dispatcher/klass_transform.rb', line 141

def to_class_string(klass, options = {})
  klass = validate_klass(klass, options)
  klass = klass.titleize if options[:class_titleize]
  klass = camelize(klass) if options[:class_camelize]
  klass
end