Class: Ldaptic::ErrorSet

Inherits:
Hash
  • Object
show all
Defined in:
lib/ldaptic/error_set.rb

Instance Method Summary collapse

Methods included from Filter::Conversions

#to_ldap_filter

Constructor Details

#initialize(base) ⇒ ErrorSet

Returns a new instance of ErrorSet.



3
4
5
6
# File 'lib/ldaptic/error_set.rb', line 3

def initialize(base)
  @base = base
  super() { |h, k| h[k] = [] }
end

Instance Method Details

#add(attribute, message) ⇒ Object



8
9
10
# File 'lib/ldaptic/error_set.rb', line 8

def add(attribute, message)
  self[attribute] << message
end

#eachObject



12
13
14
15
16
17
18
# File 'lib/ldaptic/error_set.rb', line 12

def each
  each_key do |attribute|
    self[attribute].each do |message|
      yield attribute, message
    end
  end
end

#full_messagesObject



20
21
22
23
24
# File 'lib/ldaptic/error_set.rb', line 20

def full_messages
  map do |attribute, message|
    "#{@base.class.human_attribute_name(attribute)} #{message}"
  end
end

#sizeObject



30
31
32
# File 'lib/ldaptic/error_set.rb', line 30

def size
  full_messages.size
end

#to_aObject



26
27
28
# File 'lib/ldaptic/error_set.rb', line 26

def to_a
  full_messages
end