Module: Zena::Use::Conditional::ZafuMethods

Defined in:
lib/zena/use/conditional.rb

Instance Method Summary collapse

Instance Method Details

#r_seleniumObject



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

def r_selenium
  return parser_error("missing 'id'.") if @name.blank?
  out expand_if("params[:test]==#{@name.inspect} || params[:test]=='all'")
end

#rubyless_class_scope(class_name) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/zena/use/conditional.rb', line 9

def rubyless_class_scope(class_name)
  return parser_error("Cannot scope class in list (use each before filtering).") if node.list_context?
  # capital letter ==> class conditional
  if klass = VirtualClass[class_name]
    if klass.kpath =~ %r{^#{node.klass.kpath}} || @context[:saved_template]
      # Saved templates can be rendered with anything...
      # FIXME: Make sure saved templates from 'block' start with the proper node type ?
      cond     = "#{node}.kpath_match?('#{klass.kpath}')"
      new_node = node.move_to(node.name, klass)
    else
      # render nothing: incompatible classes
      cond     = 'false'
      new_node = node.move_to(node.name, klass)
    end
  elsif role = Node.get_role(class_name)
    if node.klass.kpath =~ %r{^#{role.kpath}} || @context[:saved_template]
      # Saved templates can be rendered with anything...
      # FIXME: Make sure saved templates from 'block' start with the proper node type ?
      cond     = "#{node}.has_role?(#{role.id})"
      new_node = node.move_to(node.name, node.klass)
    else
      # render nothing: incompatible classes
      cond     = 'false'
      new_node = node.move_to(node.name, node.klass)
    end
  else
    return parser_error("Invalid role or class '#{class_name}'")
  end

  if parent.method == 'case'
    with_context(:node => new_node) do
      r_elsif(cond)
    end
  else
    out expand_if(cond, new_node)
  end
end