Class: ActiveSP::ContentType

Inherits:
Base
  • Object
show all
Extended by:
Caching, PersistentCaching
Includes:
InSite, Util
Defined in:
lib/activesp/content_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attribute, #attribute_type, #attribute_types, #attributes, #has_attribute?, #has_writable_attribute?, #method_missing, #reload, #set_attribute

Constructor Details

#initialize(site, list, id, name = nil, description = nil, version = nil, group = nil) ⇒ ContentType

Returns a new instance of ContentType.



40
41
42
43
44
45
46
# File 'lib/activesp/content_type.rb', line 40

def initialize(site, list, id, name = nil, description = nil, version = nil, group = nil)
  @site, @list, @id = site, list, id
  @Name = name if name
  @Description = description if description
  @Version = version if version
  @Group = group if group
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveSP::Base

Instance Attribute Details

#idObject (readonly)



36
37
38
# File 'lib/activesp/content_type.rb', line 36

def id
  @id
end

Instance Method Details

#DescriptionObject



77
78
79
# File 'lib/activesp/content_type.rb', line 77

def Description
  data["Description"].to_s
end

#fieldsArray<Field>

Returns the list of fields defined for this content type

Returns:



96
97
98
# File 'lib/activesp/content_type.rb', line 96

def fields
  data.xpath("//sp:Field", NS).map { |field| scope.field(field["ID"]) }.compact
end

#GroupObject



89
90
91
# File 'lib/activesp/content_type.rb', line 89

def Group
  data["Group"].to_s
end

#keyString

See Base#key

Returns:

  • (String)


66
67
68
# File 'lib/activesp/content_type.rb', line 66

def key
  encode_key("T", [scope.key, @id])
end

#NameObject



71
72
73
# File 'lib/activesp/content_type.rb', line 71

def Name
  data["Name"].to_s
end

#savevoid

This method returns an undefined value.

See Base#save



103
104
105
# File 'lib/activesp/content_type.rb', line 103

def save
  p untype_cast_attributes(@site, nil, internal_attribute_types, changed_attributes)
end

#scopeSite, List

Returns the scope of the content type. This can be either a site or a list

Returns:



50
51
52
# File 'lib/activesp/content_type.rb', line 50

def scope
  @list || @site
end

#supertypeContentType?

Returns the supertype of this content type. This is the content type as defined on the containing site in case this content type has a list as scope. returns nil for a content type that has a site as scope

Returns:



58
59
60
61
# File 'lib/activesp/content_type.rb', line 58

def supertype
  superkey = split_id[0..-2].join("")
  (@list ? @list.content_type(superkey) : nil) || @site.content_type(superkey)
end

#to_sObject Also known as: inspect



108
109
110
# File 'lib/activesp/content_type.rb', line 108

def to_s
  "#<ActiveSP::ContentType Name=#{self.Name}>"
end

#VersionObject



83
84
85
# File 'lib/activesp/content_type.rb', line 83

def Version
  data["Version"].to_s
end