Method: Checkpoint::Resource#type

Defined in:
lib/checkpoint/resource.rb

#typeString

Get the resource type.

Note that this is not necessarily a class/model type name. It can be whatever type name is most useful for building tokens and inspecting grants for this types. For example, there may be objects that have subtypes that are not modeled as objects, decorators, or collection objects (like a specialized type for the root of a tree) that should be treated as the element type.

If the entity implements #resource_type, we will use that. Otherwise, we use the entity’s class name.

Returns:

  • (String)

    the name of the entity’s type after calling #to_s on it.



89
90
91
92
93
94
95
# File 'lib/checkpoint/resource.rb', line 89

def type
  if entity.respond_to?(:resource_type)
    entity.resource_type
  else
    entity.class
  end.to_s
end