Class: Springcm::AppliedAttributeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/springcm-sdk/applied_attribute_group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#method_missing, #raw

Constructor Details

#initialize(data, group_name, subject, client) ⇒ AppliedAttributeGroup

Returns a new instance of AppliedAttributeGroup.



9
10
11
12
13
# File 'lib/springcm-sdk/applied_attribute_group.rb', line 9

def initialize(data, group_name, subject, client)
  @subject = subject
  @name = group_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

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/springcm-sdk/applied_attribute_group.rb', line 7

def name
  @name
end

#subjectObject (readonly)

Returns the value of attribute subject.



6
7
8
# File 'lib/springcm-sdk/applied_attribute_group.rb', line 6

def subject
  @subject
end

Instance Method Details

#field(field_name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/springcm-sdk/applied_attribute_group.rb', line 23

def field(field_name)
  group_config = @client..attribute_group(name: name)
  set_config = group_config.set_for_field(field_name)
  field_data = nil
  if set_config.nil?
    field_data = raw[field_name]
  elsif set_config["RepeatingAttribute"]
    raise RepeatableAttributeSetUsageError.new(group.name, name)
  else
    field_data = raw[set_config["Name"]][field_name]
  end
  AppliedAttributeField.new(field_data, field_name, subject, self, nil, @client)
end

#set(set_name) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/springcm-sdk/applied_attribute_group.rb', line 15

def set(set_name)
  set_data = raw[set_name]
  if set_data.nil? || set_data["AttributeType"] != "Set"
    raise NoAttributeSetError.new(group.name, name)
  end
  AppliedAttributeSet.new(set_data, set_name, subject, self, @client)
end