Sha256: ef2d2f2450a82a5bf045cec0bdcbff5b45cb3feb91b33f8ee9c97d40cbe30634
Contents?: true
Size: 1.52 KB
Versions: 12
Compression:
Stored size: 1.52 KB
Contents
module Animoto module Support module ContentType # When included, includes the InstanceMethods module and extends the # ClassMethods module. # @return [void] def self.included base base.class_eval { include Animoto::Support::ContentType::InstanceMethods extend Animoto::Support::ContentType::ClassMethods } end module InstanceMethods # Returns the content type for this class. # # @return [String] the content type def content_type self.class.content_type end end module ClassMethods # @overload content_type(type) # Sets the content type for this class. # @param [String] content_type the type # @return [String] the content type # @overload content_type() # Returns the content type for this class. # @return [String] the content type def content_type type = nil @content_type = type if type @content_type || infer_content_type end private # If no content type is explicitly set, this will infer the name of the content # type from the class name by lowercasing and underscoring the base name of the # class. For example, Animoto::DirectingJob becomes "directing_job". # # @return [String] the inferred content type def infer_content_type name.split('::').last.underscore end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems