Class: Liza::Unit

Inherits:
Object
  • Object
show all
Defined in:
lib/liza/unit.rb

Direct Known Subclasses

Box, Controller, Panel, Part, System, Test

Defined Under Namespace

Classes: Error, RenderError, RenderStackIsEmpty, RenderStackIsFull, RendererNotFound

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object



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

def self.const_missing name
  Liza.const name
rescue Liza::ConstNotFound
  raise NameError, "uninitialized constant #{name}", caller[1..], cause: nil
end

.divisionObject

CONTROLLER



64
65
66
# File 'lib/liza/unit.rb', line 64

def self.division
  Liza::Controller
end

.part(key, klass = nil, system: nil) ⇒ Object

PART



9
10
11
# File 'lib/liza/unit.rb', line 9

def self.part key, klass = nil, system: nil
  Lizarb.connect_part self, key, klass, system
end

.systemObject

SYSTEM



70
71
72
73
74
75
76
77
# File 'lib/liza/unit.rb', line 70

def self.system
  if name&.include? "::"
    return System if first_namespace == "Liza"
    Object.const_get first_namespace
  else
    superclass.system
  end
end

.test_classObject

TEST



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

def self.test_class
  @test_class ||=
    if first_namespace == "Liza"
      Liza.const_get "#{last_namespace}Test"
    else
      Object.const_get "#{name}Test"
    end
end

Instance Method Details

#systemObject



81
82
83
# File 'lib/liza/unit.rb', line 81

def system
  self.class.system
end