Class: ActiveSP::ContentType
- Extended by:
- Caching, PersistentCaching
- Defined in:
- lib/activesp/content_type.rb
Instance Attribute Summary collapse
- #id ⇒ Object readonly
Instance Method Summary collapse
- #Description ⇒ Object
-
#fields ⇒ Array<Field>
Returns the list of fields defined for this content type.
- #fields_by_name ⇒ Object
- #Group ⇒ Object
-
#initialize(site, list, id, name = nil, description = nil, version = nil, group = nil) ⇒ ContentType
constructor
A new instance of ContentType.
-
#key ⇒ String
See Base#key.
- #Name ⇒ Object
-
#save ⇒ void
See Base#save.
-
#scope ⇒ Site, List
Returns the scope of the content type.
-
#supertype ⇒ ContentType?
Returns the supertype of this content type.
- #to_s ⇒ Object (also: #inspect)
- #Version ⇒ Object
Methods included from Caching
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
#id ⇒ Object (readonly)
36 37 38 |
# File 'lib/activesp/content_type.rb', line 36 def id @id end |
Instance Method Details
#Description ⇒ Object
77 78 79 |
# File 'lib/activesp/content_type.rb', line 77 def Description data["Description"].to_s end |
#fields ⇒ Array<Field>
Returns the list of fields defined for this content type
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 |
#fields_by_name ⇒ Object
101 102 103 |
# File 'lib/activesp/content_type.rb', line 101 def fields_by_name fields.inject({}) { |h, f| h[decode_field_name(f.StaticName)] = f ; h } end |
#Group ⇒ Object
89 90 91 |
# File 'lib/activesp/content_type.rb', line 89 def Group data["Group"].to_s end |
#key ⇒ String
See Base#key
66 67 68 |
# File 'lib/activesp/content_type.rb', line 66 def key encode_key("T", [scope.key, @id]) end |
#Name ⇒ Object
71 72 73 |
# File 'lib/activesp/content_type.rb', line 71 def Name data["Name"].to_s end |
#save ⇒ void
This method returns an undefined value.
See Base#save
108 109 110 |
# File 'lib/activesp/content_type.rb', line 108 def save p untype_cast_attributes(@site, nil, internal_attribute_types, changed_attributes) end |
#scope ⇒ Site, List
Returns the scope of the content type. This can be either a site or a list
50 51 52 |
# File 'lib/activesp/content_type.rb', line 50 def scope @list || @site end |
#supertype ⇒ ContentType?
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
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_s ⇒ Object Also known as: inspect
113 114 115 |
# File 'lib/activesp/content_type.rb', line 113 def to_s "#<ActiveSP::ContentType Name=#{self.Name}>" end |
#Version ⇒ Object
83 84 85 |
# File 'lib/activesp/content_type.rb', line 83 def Version data["Version"].to_s end |