Class: AEMReference::AllElements

Inherits:
MultipleElements show all
Defined in:
lib/_aem/aemreference.rb

Constant Summary collapse

KeyForm =

Note that an AllElements object is a wrapper around an UnkeyedElements object. When sub-selecting these elements, e.g. ref.elements(‘docu’).by_index(1), the AllElements wrapper is ignored and the UnkeyedElements object is used as the basis for the new specifier. e.g.

AEM.app.elements(‘docu’) # every document of application

produces the following chain:

ApplicationRoot -> UnkeyedElements -> AllElements

Subselecting these elements, e.g.

AEM.app.elements(‘docu’).by_index(1) # document 1 of application

produces the following chain:

ApplicationRoot -> UnkeyedElements -> ElementByIndex

As you can see, the previous UnkeyedElements object is retained, but the AllElements object isn’t.

The result of all this is that users can legally write a reference to all elements as (e.g.):

AEM.app.elements(‘docu’) AS.app.documents

instead of:

AEM.app.elements(‘docu’).all AS.app.documents.all

Compare with some other bridges (e.g. Frontier), where (e.g.) ‘ref.documents’ is not a legitimate reference in itself, and users must remember to add ‘.all’ in order to specify all elements, or else it won’t work correctly. This maps directly onto the underlying AEM API, which is easy to implement but isn’t so good for usability. Whereas aem trades a bit of increased internal complexity for a simpler, more intuitive and foolproof external API.

AEMReference.pack_enum(KAE::FormAbsolutePosition)
All =
AEMReference.pack_absolute_ordinal(KAE::KAEAll)

Constants inherited from MultipleElements

MultipleElements::Any, MultipleElements::First, MultipleElements::Last, MultipleElements::Middle

Constants inherited from PositionSpecifier

PositionSpecifier::After, PositionSpecifier::Before, PositionSpecifier::Beginning, PositionSpecifier::End, PositionSpecifier::Next, PositionSpecifier::Previous

Instance Attribute Summary

Attributes inherited from PositionSpecifier

#AEM_want

Instance Method Summary collapse

Methods inherited from MultipleElements

#any, #by_filter, #by_id, #by_index, #by_name, #by_range, #first, #last, #middle

Methods inherited from PositionSpecifier

#_pack_self, #after, #before, #beginning, #begins_with, #contains, #elements, #end, #ends_with, #eq, #ge, #gt, #is_in, #le, #lt, #ne, #next, #previous, #property, #user_property

Methods inherited from Specifier

#AEM_pack_self, #AEM_root, #AEM_set_desc

Methods inherited from Query

#==, #AEM_comparable, #hash, #inspect

Constructor Details

#initialize(wantcode, container) ⇒ AllElements

Returns a new instance of AllElements.



662
663
664
# File 'lib/_aem/aemreference.rb', line 662

def initialize(wantcode, container)
  super(wantcode, UnkeyedElements.new(wantcode, container), All)
end

Instance Method Details

#_pack_key(codecs) ⇒ Object



670
671
672
# File 'lib/_aem/aemreference.rb', line 670

def _pack_key(codecs)
  return All
end

#AEM_resolve(obj) ⇒ Object



679
680
681
# File 'lib/_aem/aemreference.rb', line 679

def AEM_resolve(obj)
  return @_container.AEM_resolve(obj) # forward to UnkeyedElements
end

#AEM_true_selfObject



674
675
676
677
# File 'lib/_aem/aemreference.rb', line 674

def AEM_true_self
  # override default implementation to return the UnkeyedElements object stored inside of this AllElements instance
  return @_container
end

#to_sObject



666
667
668
# File 'lib/_aem/aemreference.rb', line 666

def to_s
  return @_container.to_s
end