Class: Zm::Client::Base::ZimbraAttributesCollection

Inherits:
Object
  • Object
show all
Includes:
MissingMethodStaticCollection
Defined in:
lib/zm/client/base/zimbra_attributes_collection.rb

Instance Attribute Summary collapse

Attributes included from MissingMethodStaticCollection

#all

Instance Method Summary collapse

Methods included from MissingMethodStaticCollection

#method_missing

Constructor Details

#initialize(parent) ⇒ ZimbraAttributesCollection

Returns a new instance of ZimbraAttributesCollection.



14
15
16
17
18
19
20
21
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 14

def initialize(parent)
  @parent = parent

  @all = CSV.open(File.expand_path(@parent.config.zimbra_attributes_path), headers: true, skip_blanks: true, strip: true, header_converters: lambda { |h| h.to_sym }).map do |attr|
    attr_h = attr.to_h.delete_if { |_, v| v.nil? }
    ZimbraAttribute.new(**attr_h)
  end.freeze
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class MissingMethodStaticCollection

Instance Attribute Details

#all_versionedObject (readonly)

Returns the value of attribute all_versioned.



12
13
14
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 12

def all_versioned
  @all_versioned
end

Instance Method Details

#all_account_attr_types_hObject



120
121
122
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 120

def 
  @all_account_attr_types_h ||= Hash[.map { |attr| [attr.name, attr.type] }].freeze
end

#all_account_attrsObject

############################### Account ###############################



108
109
110
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 108

def 
  @all_account_attrs ||= @all.select { |attr| attr. || attr.is_mailRecipient_scoped? }.freeze
end

#all_account_attrs_writableObject



112
113
114
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 112

def 
  @all_account_attrs_writable ||= .reject(&:immutable?).freeze
end

#all_account_attrs_writable_namesObject



116
117
118
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 116

def 
  @all_account_attrs_writable_names ||= .map(&:name).freeze
end

#all_cos_attr_types_hObject



48
49
50
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 48

def all_cos_attr_types_h
  @all_cos_attr_types_h ||= Hash[all_cos_attrs.map { |attr| [attr.name, attr.type] }].freeze
end

#all_cos_attrsObject

############################### Cos ###############################



36
37
38
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 36

def all_cos_attrs
  @all_cos_attrs ||= @all.select(&:is_cos_scoped?).freeze
end

#all_cos_attrs_writableObject



40
41
42
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 40

def all_cos_attrs_writable
  @all_cos_attrs_writable ||= all_cos_attrs.reject(&:immutable?).freeze
end

#all_cos_attrs_writable_namesObject



44
45
46
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 44

def all_cos_attrs_writable_names
  @all_cos_attrs_writable_names ||= all_cos_attrs_writable.map(&:name).freeze
end

#all_distributionlist_attrsObject

############################### Distribution List ###############################



132
133
134
135
136
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 132

def all_distributionlist_attrs
  @all_distributionlist_attrs ||= @all.select do |attr|
    attr.is_distributionList_scoped? || attr.is_group_scoped? || attr.is_groupDynamicUnit_scoped? || attr.is_groupStaticUnit_scoped?
  end.freeze
end

#all_distributionlist_attrs_types_hObject



146
147
148
149
150
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 146

def all_distributionlist_attrs_types_h
  @all_distributionlist_attrs_types_h ||= Hash[all_distributionlist_attrs.map do |attr|
                                                 [attr.name, attr.type]
                                               end].freeze
end

#all_distributionlist_attrs_writableObject



138
139
140
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 138

def all_distributionlist_attrs_writable
  @all_distributionlist_attrs_writable ||= all_distributionlist_attrs.reject(&:immutable?).freeze
end

#all_distributionlist_attrs_writable_namesObject



142
143
144
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 142

def all_distributionlist_attrs_writable_names
  @all_distributionlist_attrs_writable_names ||= all_distributionlist_attrs_writable.map(&:name).freeze
end

#all_domain_attr_types_hObject



96
97
98
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 96

def all_domain_attr_types_h
  @all_domain_attr_types_h ||= Hash[all_domain_attrs.map { |attr| [attr.name, attr.type] }].freeze
end

#all_domain_attrsObject

############################### Domain ###############################



84
85
86
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 84

def all_domain_attrs
  @all_domain_attrs ||= @all.select(&:is_domain_scoped?).freeze
end

#all_domain_attrs_writableObject



88
89
90
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 88

def all_domain_attrs_writable
  @all_domain_attrs_writable ||= all_domain_attrs.reject(&:immutable?).freeze
end

#all_domain_attrs_writable_namesObject



92
93
94
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 92

def all_domain_attrs_writable_names
  @all_domain_attrs_writable_names ||= all_domain_attrs_writable.map(&:name).freeze
end

#all_resource_attrsObject

############################### Calendar Resource ###############################



160
161
162
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 160

def all_resource_attrs
  @all_resource_attrs ||= @all.select(&:is_calendarResource_scoped?).freeze
end

#all_resource_attrs_types_hObject



172
173
174
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 172

def all_resource_attrs_types_h
  @all_resource_attrs_types_h ||= Hash[all_resource_attrs.map { |attr| [attr.name, attr.type] }].freeze
end

#all_resource_attrs_writableObject



164
165
166
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 164

def all_resource_attrs_writable
  @all_resource_attrs_writable ||= all_resource_attrs.reject(&:immutable?).freeze
end

#all_resource_attrs_writable_namesObject



168
169
170
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 168

def all_resource_attrs_writable_names
  @all_resource_attrs_writable_names ||= all_resource_attrs_writable.map(&:name).freeze
end

#all_server_attr_types_hObject



72
73
74
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 72

def all_server_attr_types_h
  @all_server_attr_types_h ||= Hash[all_server_attrs.map { |attr| [attr.name, attr.type] }].freeze
end

#all_server_attrsObject

############################### Server ###############################



60
61
62
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 60

def all_server_attrs
  @all_server_attrs ||= @all.select(&:is_server_scoped?).freeze
end

#all_server_attrs_writableObject



64
65
66
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 64

def all_server_attrs_writable
  @all_server_attrs_writable ||= all_server_attrs.reject(&:immutable?).freeze
end

#all_server_attrs_writable_namesObject



68
69
70
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 68

def all_server_attrs_writable_names
  @all_server_attrs_writable_names ||= all_server_attrs_writable.map(&:name).freeze
end

#set_account_methodsObject



124
125
126
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 124

def 
  Account.attr_accessor(*.map { |attr| attr.name.to_sym })
end

#set_cos_methodsObject



52
53
54
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 52

def set_cos_methods
  Cos.attr_accessor(*all_cos_attrs.map { |attr| attr.name.to_sym })
end

#set_distributionlist_methodsObject



152
153
154
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 152

def set_distributionlist_methods
  DistributionList.attr_accessor(*all_distributionlist_attrs.map { |attr| attr.name.to_sym })
end

#set_domain_methodsObject



100
101
102
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 100

def set_domain_methods
  Domain.attr_accessor(*all_domain_attrs.map { |attr| attr.name.to_sym })
end

#set_methodsObject



23
24
25
26
27
28
29
30
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 23

def set_methods
  set_server_methods
  set_cos_methods
  set_domain_methods
  
  set_distributionlist_methods
  set_resource_methods
end

#set_resource_methodsObject



176
177
178
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 176

def set_resource_methods
  Resource.attr_accessor(*all_resource_attrs.map { |attr| attr.name.to_sym })
end

#set_server_methodsObject



76
77
78
# File 'lib/zm/client/base/zimbra_attributes_collection.rb', line 76

def set_server_methods
  Server.attr_accessor(*all_server_attrs.map { |attr| attr.name.to_sym })
end