Module: Zena::Acts::Enrollable::ZafuMethods
- Includes:
- Common
- Defined in:
- lib/zena/acts/enrollable.rb
Overview
Common
Instance Method Summary collapse
-
#node_context_from_signature(signature) ⇒ Object
This is used to resolve ‘this’ (current NodeContext), ‘@node’ as NodeContext with class Node, ‘@page’ as first NodeContext of type Page, @letter, etc.
Methods included from Common
Instance Method Details
#node_context_from_signature(signature) ⇒ Object
This is used to resolve ‘this’ (current NodeContext), ‘@node’ as NodeContext with class Node, ‘@page’ as first NodeContext of type Page, @letter, etc. We overwrite Zafu’s version to cope with our anonymous classes.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/zena/acts/enrollable.rb', line 152 def node_context_from_signature(signature) return nil unless signature.size == 1 ivar = signature.first if ivar == 'this' super elsif ivar[0..0] == '@' && klass = get_class(ivar[1..-1].capitalize) if klass <= Node # We have to get 'up' class with a little more skill because of enrollable's anonymous classes. kpath = klass.kpath node = self.node while node && (node.list_context? || !(node.klass <= Node) || !(node.klass.kpath =~ /^#{kpath}/)) node = node.up end else node = self.node(klass) end if node {:class => node.klass, :method => node.name} else nil end else nil end end |