Module: ActiveCMIS::Type::ClassMethods

Includes:
Internal::Caching
Defined in:
lib/active_cmis/type.rb

Overview

Class Methods on CMIS Types

The following info is also available:

id, local_name, local_namespace, display_name, query_name, description, base_id, parent_id, creatable, fileable,
queryable, fulltext_indexed, controllable_policy, controllable_acl, versionable, content_stream_allowed

Instance Method Summary collapse

Methods included from Internal::Caching

included

Instance Method Details

#all_subtypesArray<Class>

Returns All subtypes.

Returns:

  • (Array<Class>)

    All subtypes



129
130
131
132
133
# File 'lib/active_cmis/type.rb', line 129

def all_subtypes
  subtypes.map do |t|
    t.all_subtypes
  end.flatten << self
end

#attribute_prefixes<String>

Returns A list of prefixes that can be used for adressing attributes (like cmis:).

Returns:

  • (<String>)

    A list of prefixes that can be used for adressing attributes (like cmis:)



92
93
94
95
96
97
98
# File 'lib/active_cmis/type.rb', line 92

def attribute_prefixes
  @prefixes ||= attributes(true).keys.map do |key|
    if key =~ /^([^:]+):/
      $1
    end
  end.compact.uniq
end

#attributes(inherited = false) ⇒ {String => PropertyDefinition}

Returns A list of propery definitions for all properties on the type.

Parameters:

  • inherited (Boolean) (defaults to: false)

    (false) Ignored

Returns:

  • ({String => PropertyDefinition})

    A list of propery definitions for all properties on the type



77
78
79
80
81
82
83
84
# File 'lib/active_cmis/type.rb', line 77

def attributes(inherited = false)
  load_from_data unless defined?(@attributes)
  if inherited && superclass.respond_to?(:attributes)
    super.merge(@attributes)
  else
    @attributes
  end
end

#inspectString

Returns:

  • (String)


107
108
109
# File 'lib/active_cmis/type.rb', line 107

def inspect
  "#<#{repository.key}::Class #{key}>"
end

#keyString

Returns The CMIS ID of the type.

Returns:

  • (String)

    The CMIS ID of the type



112
113
114
# File 'lib/active_cmis/type.rb', line 112

def key
  @key ||= data.xpath("cra:type/c:id", NS::COMBINED).text
end

#reloadvoid

This method returns an undefined value.



101
102
103
104
# File 'lib/active_cmis/type.rb', line 101

def reload
  remove_instance_variable(:@attributes) if defined? @attributes
  [:attributes] + __reload # Could also do if defined?(super) then super else __reload end, but we don't do anything but remove_instance_variable @attributes in superclasses anyway
end

#required_attributes{String => PropertyDefinition}

Returns A list of all required definitions (includes inherited attributes).

Returns:

  • ({String => PropertyDefinition})

    A list of all required definitions (includes inherited attributes)



87
88
89
# File 'lib/active_cmis/type.rb', line 87

def required_attributes
  attributes(true).reject {|key, value| !value.required}
end

#subtypesCollection<Class>

Returns All direct subtypes (1 level deep).

Returns:

  • (Collection<Class>)

    All direct subtypes (1 level deep)



117
118
119
120
121
122
123
124
125
# File 'lib/active_cmis/type.rb', line 117

def subtypes
  types_feed = Internal::Utils.extract_links(data, 'down', 'application/atom+xml', 'type' => 'feed')
  raise "No subtypes link for #{id}" if types_feed.empty?

  Collection.new(repository, types_feed.first) do |entry|
    id = entry.xpath("cra:type/c:id", NS::COMBINED).text
    repository.type_by_id id
  end
end