Module: AD::Framework::Patterns::HasSchema::InstanceMethods

Defined in:
lib/ad-framework/patterns/has_schema.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



32
33
34
35
36
# File 'lib/ad-framework/patterns/has_schema.rb', line 32

def attributes
  self.schema.attributes.inject({}) do |attrs, name|
    attrs.merge({ name.to_sym => self.send(name.to_sym) })
  end
end

#attributes=(new_attributes) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/ad-framework/patterns/has_schema.rb', line 37

def attributes=(new_attributes)
  new_attributes.each do |name, value|
    if self.schema.attributes.include?(name)
      self.send("#{name}=", value)
    end
  end
end

#dnObject



25
26
27
28
29
30
# File 'lib/ad-framework/patterns/has_schema.rb', line 25

def dn
  dn = self.fields[:distinguishedname] || self.fields[:dn]
  dn ||= if self.respond_to?(self.schema.rdn)
    [ "CN=#{self.send(self.schema.rdn)}", self.schema.treebase ].join(", ")
  end
end

#schemaObject



21
22
23
# File 'lib/ad-framework/patterns/has_schema.rb', line 21

def schema
  @schema ||= self.class.schema.dup
end