Sha256: 97096163e76f31a792020d8513eaed3906ef8b9c6036812cf1b21d3b88bfc168

Contents?: true

Size: 980 Bytes

Versions: 2

Compression:

Stored size: 980 Bytes

Contents

module Praxis
  module Types

    # Traits that are shared by MediaType and SimpleMediaType.
    module MediaTypeCommon
      extend ::ActiveSupport::Concern

      module ClassMethods
        def describe(shallow = false)
          hash = super
          unless shallow
            hash.merge!(identifier: @identifier.to_s, description: @description)
          end
          hash
        end

        def description(text=nil)
          @description = text if text
          @description
        end

        # Get or set the identifier of this media type.
        #
        # @deprecated this method is not deprecated, but its return type will change to MediaTypeIdentifier in Praxis 1.0
        #
        # @return [String] the string-representation of this type's identifier
        def identifier(identifier=nil)
          return @identifier.to_s unless identifier
          (@identifier = MediaTypeIdentifier.load(identifier)).to_s
        end
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
praxis-0.16.1 lib/praxis/types/media_type_common.rb
praxis-0.16.0 lib/praxis/types/media_type_common.rb