class String
Public Instance Methods
to_boolean(default = nil)
click to toggle source
Convets to boolean. Returns true for 'true', '1', 'yes', 'on' and 't'. Returns false for 'false', '0', 'no', 'off' and 'f'. @param [Boolean] default Default value to return when the String
is not interpretable @return [Boolean] Convered boolean value
# File lib/activity_notification/helpers/polymorphic_helpers.rb, line 37 def to_boolean(default = nil) return true if ['true', '1', 'yes', 'on', 't'].include? self return false if ['false', '0', 'no', 'off', 'f'].include? self return default end
to_model_class()
click to toggle source
Convets to model class. @return [Class] Model class
# File lib/activity_notification/helpers/polymorphic_helpers.rb, line 16 def to_model_class to_model_name.classify.constantize end
to_model_name()
click to toggle source
Convets to model instance. @return [Object] Model instance
# File lib/activity_notification/helpers/polymorphic_helpers.rb, line 10 def to_model_name singularize.camelize end
to_resource_name()
click to toggle source
Convets to singularized model name (resource name). @return [String] Singularized model name (resource name)
# File lib/activity_notification/helpers/polymorphic_helpers.rb, line 22 def to_resource_name singularize.underscore end
to_resources_name()
click to toggle source
Convets to pluralized model name (resources name). @return [String] Pluralized model name (resources name)
# File lib/activity_notification/helpers/polymorphic_helpers.rb, line 28 def to_resources_name pluralize.underscore end