Sha256: 135af4b2ae9bb2a5edd6a473eff1d51f70dec330fa538711f3cd04ffa9b40142

Contents?: true

Size: 938 Bytes

Versions: 3

Compression:

Stored size: 938 Bytes

Contents

module ActiveLdap
  module AttributeMethods
    extend ActiveSupport::Concern
    include ActiveModel::AttributeMethods

    def methods(singleton_methods = true)
      target_names = entry_attribute.all_names
      target_names -= ['objectClass', 'objectClass'.underscore]
      super + target_names.uniq.collect do |attr|
        method_patterns = 
          if self.class.respond_to?(:attribute_method_patterns)
            # Support for ActiveModel >= 7.1.0
            self.class.attribute_method_patterns
          else
            # Support for ActiveModel < 7.1.0
            self.class.attribute_method_matchers
          end
        
        method_patterns.collect do |pattern|
          pattern.method_name(attr).to_sym
        end
      end.flatten
    end

    private
    # overiding ActiveModel::AttributeMethods
    def attribute_method?(method_name)
      have_attribute?(method_name, ['objectClass'])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activeldap-7.2.1 lib/active_ldap/attribute_methods.rb
activeldap-7.2.0 lib/active_ldap/attribute_methods.rb
activeldap-7.0.0 lib/active_ldap/attribute_methods.rb