Class: Ldap::LdapArray

Inherits:
DataMapper::Property::Text
  • Object
show all
Defined in:
lib/ldap/array.rb

Instance Method Summary collapse

Constructor Details

#initialize(_model = nil, _name = nil, options = {}, *args) ⇒ LdapArray

keep the *args so it works for both DM-1.1.x and DM-1.0.x



78
79
80
81
82
83
# File 'lib/ldap/array.rb', line 78

def initialize(_model = nil, _name = nil, options = {}, *args)
  super

  add_writer(model,name) unless options[:writer] == :private || options[:accessor] == :private
  add_reader(model,name) unless options[:reader] == :private || options[:accessor] == :private        
end

Instance Method Details

#custom?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/ldap/array.rb', line 50

def custom?
  true
end

#dump(value) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/ldap/array.rb', line 67

def dump(value)
  result = case value
           when LdapArray then '"' + value.join('","') + '"'
           when ::Array then '"' + value.join('","') + '"'
           when ::String then '"' + value.to_s + '"'
           else
             nil
           end
end

#load(value) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/ldap/array.rb', line 58

def load(value)
  result = case value
           when ::String then value[1, value.size-2].split('","').to_a.freeze
           when ::Array then value.freeze
           else
             []
           end
end

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/ldap/array.rb', line 54

def primitive?(value)
  super || value.kind_of?(::Array)
end