Module: ActiveLdap::HumanReadable::ClassMethods
- Defined in:
- lib/active_ldap/human_readable.rb
Instance Method Summary collapse
- #human_attribute_description(attribute_or_name) ⇒ Object
- #human_attribute_description_msgid(attribute_or_name) ⇒ Object
- #human_attribute_name(attribute_or_name) ⇒ Object
- #human_attribute_name_msgid(attribute_or_name) ⇒ Object
- #human_object_class_description(object_class_or_name) ⇒ Object
- #human_object_class_description_msgid(object_class_or_name) ⇒ Object
- #human_object_class_name(object_class_or_name) ⇒ Object
- #human_object_class_name_msgid(object_class_or_name) ⇒ Object
- #human_readable_format(object) ⇒ Object
- #human_syntax_description(syntax_or_id) ⇒ Object
- #human_syntax_description_msgid(syntax_or_id) ⇒ Object
- #human_syntax_name(syntax_or_id) ⇒ Object
- #human_syntax_name_msgid(syntax_or_id) ⇒ Object
Instance Method Details
#human_attribute_description(attribute_or_name) ⇒ Object
31 32 33 34 35 |
# File 'lib/active_ldap/human_readable.rb', line 31 def human_attribute_description(attribute_or_name) msgid = human_attribute_description_msgid(attribute_or_name) return nil if msgid.nil? s_(msgid) end |
#human_attribute_description_msgid(attribute_or_name) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_ldap/human_readable.rb', line 37 def human_attribute_description_msgid(attribute_or_name) if attribute_or_name.is_a?(Schema::Attribute) attribute = attribute_or_name else attribute = schema.attribute(attribute_or_name) return nil if attribute.nil? end description = attribute.description return nil if description.nil? "LDAP|Description|Attribute|#{attribute.name}|#{description}" end |
#human_attribute_name(attribute_or_name) ⇒ Object
9 10 11 12 13 |
# File 'lib/active_ldap/human_readable.rb', line 9 def human_attribute_name(attribute_or_name) msgid = human_attribute_name_msgid(attribute_or_name) msgid ||= human_attribute_name_with_gettext(attribute_or_name) s_(msgid) end |
#human_attribute_name_msgid(attribute_or_name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_ldap/human_readable.rb', line 15 def human_attribute_name_msgid(attribute_or_name) if attribute_or_name.is_a?(Schema::Attribute) name = attribute_or_name.name else attribute = schema.attribute(attribute_or_name) return nil if attribute.id.nil? if attribute.name == attribute_or_name or attribute.aliases.include?(attribute_or_name) name = attribute_or_name else return nil end end "LDAP|Attribute|#{name}" end |
#human_object_class_description(object_class_or_name) ⇒ Object
62 63 64 65 66 |
# File 'lib/active_ldap/human_readable.rb', line 62 def human_object_class_description(object_class_or_name) msgid = human_object_class_description_msgid(object_class_or_name) return nil if msgid.nil? s_(msgid) end |
#human_object_class_description_msgid(object_class_or_name) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/active_ldap/human_readable.rb', line 68 def human_object_class_description_msgid(object_class_or_name) if object_class_or_name.is_a?(Schema::ObjectClass) object_class = object_class_or_name else object_class = schema.object_class(object_class_or_name) return nil if object_class.nil? end description = object_class.description return nil if description.nil? "LDAP|Description|ObjectClass|#{object_class.name}|#{description}" end |
#human_object_class_name(object_class_or_name) ⇒ Object
49 50 51 |
# File 'lib/active_ldap/human_readable.rb', line 49 def human_object_class_name(object_class_or_name) s_(human_object_class_name_msgid(object_class_or_name)) end |
#human_object_class_name_msgid(object_class_or_name) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/active_ldap/human_readable.rb', line 53 def human_object_class_name_msgid(object_class_or_name) if object_class_or_name.is_a?(Schema::ObjectClass) name = object_class_or_name.name else name = object_class_or_name end "LDAP|ObjectClass|#{name}" end |
#human_readable_format(object) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/active_ldap/human_readable.rb', line 111 def human_readable_format(object) case object when Array "[#{object.collect {|value| human_readable_format(value)}.join(', ')}]" when Hash formatted_values = [] object.each do |key, value| formatted_values << [human_readable_format(key), human_readable_format(value)].join("=>") end "{#{formatted_values.join(', ')}}" else if object.respond_to?(:to_human_readable_format) object.to_human_readable_format else object.inspect end end end |
#human_syntax_description(syntax_or_id) ⇒ Object
93 94 95 96 97 |
# File 'lib/active_ldap/human_readable.rb', line 93 def human_syntax_description(syntax_or_id) msgid = human_syntax_description_msgid(syntax_or_id) return nil if msgid.nil? s_(msgid) end |
#human_syntax_description_msgid(syntax_or_id) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/active_ldap/human_readable.rb', line 99 def human_syntax_description_msgid(syntax_or_id) if syntax_or_id.is_a?(Schema::Syntax) syntax = syntax_or_id else syntax = schema.ldap_syntax(syntax_or_id) return nil if syntax.nil? end description = syntax.description return nil if description.nil? "LDAP|Description|Syntax|#{syntax.id}|#{description}" end |
#human_syntax_name(syntax_or_id) ⇒ Object
80 81 82 |
# File 'lib/active_ldap/human_readable.rb', line 80 def human_syntax_name(syntax_or_id) s_(human_syntax_name_msgid(syntax_or_id)) end |