Module: ActiveLdap::Helper
- Included in:
- ActionView::Base
- Defined in:
- lib/active_ldap/helper.rb
Instance Method Summary collapse
- #ldap_attribute_description_gettext(attribute) ⇒ Object (also: #lad_)
- #ldap_attribute_name_gettext(attribute) ⇒ Object (also: #la_)
- #ldap_field(type, object_name, method, options = {}) ⇒ Object
- #ldap_object_class_description_gettext(object_class) ⇒ Object (also: #locd_)
- #ldap_object_class_name_gettext(object_class) ⇒ Object (also: #loc_)
- #ldap_syntax_description_gettext(syntax) ⇒ Object (also: #lsd_)
- #ldap_syntax_name_gettext(syntax) ⇒ Object (also: #ls_)
Instance Method Details
#ldap_attribute_description_gettext(attribute) ⇒ Object Also known as: lad_
8 9 10 |
# File 'lib/active_ldap/helper.rb', line 8 def ldap_attribute_description_gettext(attribute) Base.human_attribute_description(attribute) end |
#ldap_attribute_name_gettext(attribute) ⇒ Object Also known as: la_
3 4 5 |
# File 'lib/active_ldap/helper.rb', line 3 def ldap_attribute_name_gettext(attribute) Base.human_attribute_name(attribute) end |
#ldap_field(type, object_name, method, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/active_ldap/helper.rb', line 33 def ldap_field(type, object_name, method, ={}) case type when "radio_button", "check_box", "text_area" form_method = type else form_method = "#{type}_field" end object = [:object] if object.nil? normalized_object_name = object_name.to_s.sub(/\[\](\])?$/, "\\1") object = instance_variable_get("@#{normalized_object_name}") end values = object.nil? ? nil : object[method, true] values = [nil] if values.blank? = .delete(:ldap_options) || [] .each do |required_ldap_option| found = false values.each do |value| next unless value.is_a?(Hash) if Hash.to_a[0].to_s == required_ldap_option.to_s found = true break end end values << {required_ldap_option => ""} unless found end fields = [] collect_values = Proc.new do |value, | case value when Hash value.each do |k, v| collect_values.call(v, + [k]) end when Array value.each do |v| collect_values.call(v, ) end else id = "#{object_name}_#{method}" name = "#{object_name}[#{method}][]" .collect.each do |ldap_option| id << "_#{ldap_option}" name << "[#{ldap_option}][]" end = {:id => id, :name => name, :value => value} field = send(form_method, object_name, method, .merge()) if block_given? field = yield(field, {:options => , :value => value}) end fields << field unless field.blank? end end collect_values.call(values, []) fields.join("\n") end |
#ldap_object_class_description_gettext(object_class) ⇒ Object Also known as: locd_
18 19 20 |
# File 'lib/active_ldap/helper.rb', line 18 def ldap_object_class_description_gettext(object_class) Base.human_object_class_description(object_class) end |
#ldap_object_class_name_gettext(object_class) ⇒ Object Also known as: loc_
13 14 15 |
# File 'lib/active_ldap/helper.rb', line 13 def ldap_object_class_name_gettext(object_class) Base.human_object_class_name(object_class) end |
#ldap_syntax_description_gettext(syntax) ⇒ Object Also known as: lsd_
28 29 30 |
# File 'lib/active_ldap/helper.rb', line 28 def ldap_syntax_description_gettext(syntax) Base.human_syntax_description(syntax) end |
#ldap_syntax_name_gettext(syntax) ⇒ Object Also known as: ls_
23 24 25 |
# File 'lib/active_ldap/helper.rb', line 23 def ldap_syntax_name_gettext(syntax) Base.human_syntax_name(syntax) end |