Sha256: 94c4938747791882e52b795f3493ce3e77ba78341ea3f7cd9e27b106bc23dffd

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 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, **opts)
          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.17.1 lib/praxis/types/media_type_common.rb
praxis-0.17.0 lib/praxis/types/media_type_common.rb