Class: MxHero::API::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/directories.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Directory

Returns a new instance of Directory.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/directories.rb', line 9

def initialize(data = {})
  return if data.empty?
  [
    :domain, [:type, :directoryType], [:address, :addres], :port,
    [:ssl, :sslFlag], :user, :password, :filter, :base,
    [:next_update, :nextUpdate],
    [:last_update, :lastUpdate],
    :error, [:override, :overrideFlag],
    [:dn_authenticate, :dnAuthenticate],
    :useMailAsMain
  ].each do |property|
    case property
    when Symbol
      send "#{property}=", data[property]
    when Array
      send "#{property.first}=", data[property.first] || data[property.last]
    end
  end
  load_properties(data)
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/directories.rb', line 4

def address
  @address
end

#baseObject

Returns the value of attribute base.



4
5
6
# File 'lib/directories.rb', line 4

def base
  @base
end

#dn_authenticateObject

Returns the value of attribute dn_authenticate.



4
5
6
# File 'lib/directories.rb', line 4

def dn_authenticate
  @dn_authenticate
end

#domainObject

Returns the value of attribute domain.



4
5
6
# File 'lib/directories.rb', line 4

def domain
  @domain
end

#errorObject

Returns the value of attribute error.



4
5
6
# File 'lib/directories.rb', line 4

def error
  @error
end

#filterObject

Returns the value of attribute filter.



4
5
6
# File 'lib/directories.rb', line 4

def filter
  @filter
end

#last_updateObject

Returns the value of attribute last_update.



4
5
6
# File 'lib/directories.rb', line 4

def last_update
  @last_update
end

#next_updateObject

Returns the value of attribute next_update.



4
5
6
# File 'lib/directories.rb', line 4

def next_update
  @next_update
end

#overrideObject

Returns the value of attribute override.



4
5
6
# File 'lib/directories.rb', line 4

def override
  @override
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/directories.rb', line 4

def password
  @password
end

#portObject

Returns the value of attribute port.



4
5
6
# File 'lib/directories.rb', line 4

def port
  @port
end

#propertiesObject

Returns the value of attribute properties.



4
5
6
# File 'lib/directories.rb', line 4

def properties
  @properties
end

#sslObject

Returns the value of attribute ssl.



4
5
6
# File 'lib/directories.rb', line 4

def ssl
  @ssl
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/directories.rb', line 4

def type
  @type
end

#useMailAsMainObject

Returns the value of attribute useMailAsMain.



4
5
6
# File 'lib/directories.rb', line 4

def useMailAsMain
  @useMailAsMain
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/directories.rb', line 4

def user
  @user
end

Instance Method Details

#to_hashObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/directories.rb', line 43

def to_hash
  {
    domain: domain,
    directoryType: type,
    addres: address,
    port: port,
    sslFlag: ssl, # || false,
    user: user, password: password,
    filter: filter, base: base,
    nextUpdate: next_update, # || DateTime.now.strftime('%Q'),
    lastUpdate: last_update, # || DateTime.now.strftime('%Q'),
    error: error,
    overrideFlag: override,  #override.nil? ? true : override,
    dnAuthenticate: dn_authenticate,
    useMailAsMain: useMailAsMain,
    properties: properties_field_to_hash
  }
end

#to_jsonObject



62
63
64
# File 'lib/directories.rb', line 62

def to_json
  to_hash.to_json
end

#update_properties(properties) ⇒ Object



39
40
41
# File 'lib/directories.rb', line 39

def update_properties(properties)
  properties.each { |prop, value| send("#{prop}=", value) if respond_to?("#{prop}=") }
end