Class: LdapConverters::ArrayOfJSON

Inherits:
ArrayValue show all
Defined in:
lib/ldap_converters.rb

Overview

Convert LDAP Array of JSON strings to array of ruby objects

Instance Attribute Summary

Attributes inherited from Base

#model

Instance Method Summary (collapse)

Methods inherited from ArrayValue

#validate

Methods inherited from Base

#initialize, #validate

Constructor Details

This class inherits a constructor from LdapConverters::Base

Instance Method Details

- (Object) read(value)



97
98
99
100
101
102
103
104
105
# File 'lib/ldap_converters.rb', line 97

def read(value)
  Array(value).map do |n|
    begin
      JSON.parse(n)
    rescue JSON::ParserError
      JSON::ParserError
    end
  end.select{|v| v != JSON::ParserError}
end

- (Object) write(value)



107
108
109
# File 'lib/ldap_converters.rb', line 107

def write(value)
  Array(value).map{|v| v.to_json}
end