Class: Zena::Use::NodeContext

Inherits:
Zafu::NodeContext show all
Defined in:
lib/zena/use/node_context.rb

Instance Attribute Summary

Attributes inherited from Zafu::NodeContext

#dom_prefix, #klass, #name, #opts, #saved_dom_id, #up

Instance Method Summary collapse

Methods inherited from Zafu::NodeContext

#as_main, #dom_id, #form_name, #get, #initialize, #list_context?, #master_class, #move_to, #propagate_dom_scope!, #raw_dom_prefix, #single_class, #to_s, #underscore

Constructor Details

This class inherits a constructor from Zafu::NodeContext

Instance Method Details

#class_nameObject

Return the ‘real’ class name or the superclass name if the current class is an anonymous class.



54
55
56
57
58
59
60
# File 'lib/zena/use/node_context.rb', line 54

def class_name
  if list_context?
    "[#{real_single_class}]"
  else
    real_single_class.name
  end
end

#node_klass?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/zena/use/node_context.rb', line 4

def node_klass?
  single_class.kind_of?(VirtualClass)
end

#real_classObject



16
17
18
19
20
21
22
# File 'lib/zena/use/node_context.rb', line 16

def real_class
  @real_class ||= if node_klass?
    klass.kind_of?(Array) ? [klass.first.real_class] : klass.real_class
  else
    klass
  end
end

#real_single_classObject



8
9
10
11
12
13
14
# File 'lib/zena/use/node_context.rb', line 8

def real_single_class
  @real_single_class ||= if node_klass?
    single_class.real_class
  else
    single_class
  end
end

#will_be?(type) ⇒ Boolean

Return true if the NodeContext represents an element of the given type. We use ‘will_be’ because it is equivalent to ‘is_a’, but for future objects (during rendering).

Returns:

  • (Boolean)


26
27
28
29
30
31
32
# File 'lib/zena/use/node_context.rb', line 26

def will_be?(type)
  if node_klass?
    real_single_class <= type
  else
    super
  end
end