Class: CafeCar::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/cafe_car/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(template, prefix: nil) ⇒ Context

Returns a new instance of Context.



3
4
5
6
# File 'lib/cafe_car/context.rb', line 3

def initialize(template, prefix: nil)
  @template = template
  @prefix   = prefix
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



12
13
14
15
# File 'lib/cafe_car/context.rb', line 12

def method_missing(name, ...)
  c = CafeCar[:UI].const_try(name) || Component
  c.new(@template, [ *@prefix, name ], ...)
end

Instance Method Details

#<<(obj) ⇒ Object

def wrapper(…) = Component.new(@template, [*@prefix], …).wrapper(…)



10
# File 'lib/cafe_car/context.rb', line 10

def <<(obj)          = @template.concat(obj)

#class(name) ⇒ Object



8
9
# File 'lib/cafe_car/context.rb', line 8

def class(name, ...) = @template.ui_class([ *@prefix, *name ], ...)
# def wrapper(...)     = Component.new(@template, [*@prefix], ...).wrapper(...)