Class: Scrivito::Attribute Deprecated
- Inherits:
-
Object
- Object
- Scrivito::Attribute
- Defined in:
- lib/scrivito/attribute.rb
Overview
This class represents a CMS attribute. Attributes can be created, updated, deleted and all attribute properties can be read. Attributes are part of an ObjClass and therefore each attribute belongs to exactly one ObjClass. Most of the operations interact with the currently selected Workspace. Operations like create
, destroy
and update
need to be performed in the “rtc” workspace.
Instance Attribute Summary collapse
- #obj_class ⇒ Scrivito::ObjClass readonly deprecated Deprecated.
Instance Method Summary collapse
- #destroy ⇒ nil deprecated Deprecated.
- #initialize(properties) ⇒ Scrivito::Attribute constructor deprecated Deprecated.
- #name ⇒ String deprecated Deprecated.
- #type ⇒ String deprecated Deprecated.
- #update(properties) ⇒ nil deprecated Deprecated.
- #values ⇒ Array<String> deprecated Deprecated.
Constructor Details
#initialize(properties) ⇒ Scrivito::Attribute
Initializes a new attribute.
This allows you to set the different properties of an attribute by providing a Hash with the property names as keys and the values you want to set as values.
35 36 37 38 39 |
# File 'lib/scrivito/attribute.rb', line 35 def initialize(properties) raise ScrivitoError, 'Please provide a hash of Attribute properties.' unless properties update_instance_properties(properties) end |
Instance Attribute Details
#obj_class ⇒ Scrivito::ObjClass
Returns the obj class this attribute belongs to.
70 71 72 |
# File 'lib/scrivito/attribute.rb', line 70 def obj_class @obj_class end |
Instance Method Details
#destroy ⇒ nil
Destroys this attribute and persists the change in the CMS.
117 118 119 |
# File 'lib/scrivito/attribute.rb', line 117 def destroy Scrivito.raise_obj_class_deprecated_error end |
#name ⇒ String
Returns the name of this attribute.
45 46 47 |
# File 'lib/scrivito/attribute.rb', line 45 def name @name end |
#type ⇒ String
Returns the type of this attribute. The type is either string
, text
, html
, linklist
, link
, reference
, referencelist
, date
, binary
, widget
, enum
or multienum
.
54 55 56 |
# File 'lib/scrivito/attribute.rb', line 54 def type @type end |
#update(properties) ⇒ nil
Updates this attribute and persists the changes in the CMS on its obj class. The obj_class
and name
of this attribute can not be updated.
See #initialize for a detailed overview of what properties are allowed and how to set them.
104 105 106 |
# File 'lib/scrivito/attribute.rb', line 104 def update(properties) Scrivito.raise_obj_class_deprecated_error end |
#values ⇒ Array<String>
Returns the values of this attribute, if it is of type enum
or multienum
.
62 63 64 |
# File 'lib/scrivito/attribute.rb', line 62 def values @values end |