Module: Liza

Defined in:
lib/liza.rb

Defined Under Namespace

Classes: AppTest, Box, BoxTest, ClassTest, ConstNotFound, Controller, ControllerTest, Error, LizaTest, LizarbTest, ModuleTest, ObjectTest, Panel, PanelTest, Part, PartTest, StringTest, System, SystemTest, Test, TestTest, Unit, UnitTest

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



17
18
19
# File 'lib/liza.rb', line 17

def [] name
  const name
end

.const(name) ⇒ Object

Checks Object, each system, then Liza, only returns if they are Liza::Unit descendants



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/liza.rb', line 22

def const name
  name = name.to_s.camelize.to_sym

  k = const_check_object name
  return k if k

  k = const_check_systems name
  return k if k

  k = const_get_liza name
  return k if k

  nil
end

.const_check_object(name) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/liza.rb', line 45

def const_check_object name
  return if not Object.const_defined? name
  kk = Object.const_get name
  return kk if is_unit? kk

  nil
end

.const_check_systems(name) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/liza.rb', line 53

def const_check_systems name
  App.systems.frozen? or return nil

  for k in App.systems.values.reverse
    next if not k.const_defined? name.to_sym
    kk = k.const(name) if k.constants.include? name
    return kk if is_unit? kk
  end

  nil
end

.const_get_liza(name) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/liza.rb', line 65

def const_get_liza name
  const_get name
rescue NameError => _e
  log "Liza const #{name} not found!" if $VERBOSE
  if Lizarb.ruby_supports_raise_cause?
    raise ConstNotFound, name, cause: nil
  else
    raise ConstNotFound, name, []
  end
end

.const_missing(name) ⇒ Object

Checks each system, then Liza, only returns if they are Liza::Unit descendants



38
39
40
41
42
43
# File 'lib/liza.rb', line 38

def const_missing name
  k = const_check_systems name
  return k if k

  super
end

.is_unit?(kk) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/liza.rb', line 76

def is_unit? kk
  kk && kk < Liza::Unit
end

.log(s) ⇒ Object



11
12
13
# File 'lib/liza.rb', line 11

def log s
  puts s
end