Project

General

Profile

« Previous | Next » 

Revision c2c26953

Added by Marc Dequènes over 13 years ago

  • ID c2c269539e77e757f52a43ef19de5c5c6f85ae1e

[evol] virtual attributes support §2 (aspect vattrs with example) (refs #141)

View differences:

lib/ldap_shadows/elements.rb
@cast_rel_done = true
end
def virtual_attributes
(@virtual_attributes || {}).keys
end
def ldap_virtual_attr(attr, syntax, single_value = false, binary = false)
@virtual_attributes ||= {}
@virtual_attributes[attr.to_s] = {
:syntax => syntax,
:single_value => single_value,
:binary => binary
}
end
def real_attribute_info(attr)
attr_info = ActiveLdap::Base.schema.attribute(attr)
return if attr_info.nil?
{
:syntax => attr_info.syntax.to_param,
:single_value => attr_info.single_value?,
:read_only => attr_info.read_only?,
:binary => attr_info.binary?
}
end
def virtual_attribute_info(attr)
info = (@virtual_attributes || {})[attr.to_s]
return if info.nil?
info.dup.merge({
:read_only => (not self.instance_methods.include?("#{attr}="))
})
end
# default empty hooks
def hook_before_create(item); end
def hook_before_modify(item); end

Also available in: Unified diff