Class: Springcm::AppliedAttributeSet
- Defined in:
- lib/springcm-sdk/applied_attribute_set.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #[]=(key, data) ⇒ Object
- #field(field_name) ⇒ Object
-
#initialize(data, set_name, subject, group, client) ⇒ AppliedAttributeSet
constructor
A new instance of AppliedAttributeSet.
Methods inherited from Object
Constructor Details
#initialize(data, set_name, subject, group, client) ⇒ AppliedAttributeSet
Returns a new instance of AppliedAttributeSet.
11 12 13 14 15 16 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 11 def initialize(data, set_name, subject, group, client) @subject = subject @group = group @name = set_name super(data, client) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Springcm::Object
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
8 9 10 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 8 def group @group end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 9 def name @name end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
7 8 9 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 7 def subject @subject end |
Instance Method Details
#[](*args) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 30 def [](*args) if repeating_attribute == true item = @data["Items"].send(:[], *args) AppliedAttributeSetItem.new(item, subject, group, self, @client) else raise NonRepeatableAttributeSetUsageError.new(group.name, name) end end |
#[]=(key, data) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 39 def []=(key, data) if repeating_attribute == true raise NonRepeatableAttributeSetUsageError.new(group.name, name) end group_config = @client.account.attribute_group(name: group.name) set = group_config.set(name) item = @data["Items"][key] item.clear data.each { |key, value| field_config = group_config.field(key) item[key] = Helpers.serialize_field(field_config, value) } item end |
#field(field_name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/springcm-sdk/applied_attribute_set.rb', line 18 def field(field_name) # Validate name not one of the restricted attribute names: # RepeatingAttribute, AttributeType field_data = raw[field_name] # puts field_data if repeating_attribute == true raise RepeatableAttributeSetUsageError.new(group.name, name) else AppliedAttributeField.new(field_data, field_name, subject, group, self, @client) end end |