Sha256: f4383563159398a600ed4586ff5b6f2097ff6cc8c2bbcf00ba1a710d1f31ac06

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

module Praxis
  module Types

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

      module ClassMethods
        def as_json_schema(**args)
          the_type = @attribute && @attribute.type || member_type
          the_type.as_json_schema(args)
        end

        def json_schema_type
          the_type = @attribute && @attribute.type || member_type
          the_type.json_schema_type
        end
    
        def description(text=nil)
          @description = text if text
          @description
        end

        def display_name( string=nil )
          unless string
            return  @display_name ||= self.name.split("::").last  # Best guess at a display name?
          end
          @display_name = string
        end

        # Get or set the identifier of this media type.
        #
        # @return [MediaTypeIdentifier] the string-representation of this type's identifier
        def identifier(identifier=nil)
          return @identifier unless identifier
          @identifier = MediaTypeIdentifier.load(identifier)
        end
      end

    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
praxis-2.0.pre.18 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.17 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.16 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.15 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.14 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.13 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.12 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.11 lib/praxis/types/media_type_common.rb
praxis-2.0.pre.10 lib/praxis/types/media_type_common.rb