Module: Praxis::Types::MediaTypeCommon::ClassMethods

Defined in:
lib/praxis/types/media_type_common.rb

Instance Method Summary collapse

Instance Method Details

#describe(shallow = false, **opts) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/praxis/types/media_type_common.rb', line 9

def describe(shallow = false, **opts)
  hash = super
  unless shallow
    hash.merge!(identifier: @identifier.to_s, description: @description, display_name: self.display_name)
  end
  hash
end

#description(text = nil) ⇒ Object



17
18
19
20
# File 'lib/praxis/types/media_type_common.rb', line 17

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

#display_name(string = nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/praxis/types/media_type_common.rb', line 22

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

#identifier(identifier = nil) ⇒ String

Deprecated.

this method is not deprecated, but its return type will change to MediaTypeIdentifier in Praxis 1.0

Get or set the identifier of this media type.

Returns:

  • (String)

    the string-representation of this type’s identifier



34
35
36
37
# File 'lib/praxis/types/media_type_common.rb', line 34

def identifier(identifier=nil)
  return @identifier.to_s unless identifier
  (@identifier = MediaTypeIdentifier.load(identifier)).to_s
end