Module: Subjoin::Inheritable::ClassMethods

Defined in:
lib/subjoin/inheritable.rb

Overview

Class methods for objects that include this mixin

Instance Method Summary collapse

Instance Method Details

#type_idString

class. Lower-cased name of the class unless TYPE_PATH is specified

Returns:

  • (String)

    JSON-API type corresponding to this



60
61
62
63
# File 'lib/subjoin/inheritable.rb', line 60

def type_id
  return self.to_s.downcase.gsub(/^.*::/, '') if self::TYPE_PATH.nil?
  return self::TYPE_PATH
end

#type_urlURI

of ROOT_URI and #type_id

Returns:

  • (URI)

    URI for requesting an object of this type, based



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/subjoin/inheritable.rb', line 67

def type_url
  if self.class == Resource
    raise Subjoin::SubclassError.new "Class must be a subclass of Resource to use this method"
  end

  if self::ROOT_URI.nil?
    raise Subjoin::SubclassError.new "#{self.class} or a parent of #{self.class} derived from Subjoin::Resource must override ROOT_URI to use this method"
  end

  return URI([self::ROOT_URI, self::type_id].join('/'))
end