Class: Ua::Util::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/ua/util.rb

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Helper

Returns a new instance of Helper.



4
5
6
# File 'lib/ua/util.rb', line 4

def initialize(obj)
	@obj = obj
end

Instance Method Details

#[](*args) ⇒ Object Also known as: values_at



8
9
10
11
12
13
14
# File 'lib/ua/util.rb', line 8

def [](*args)
	if args.size == 1
		@obj[args[0]]
	else
		args.map{|x| @obj[x]}
	end
end

#[]=(*args) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/ua/util.rb', line 19

def []=(*args)
	last = args.pop(1)
	args.zip(last).each{|k|
		a,b = k
		@obj[a] = b
	}
end

#appObject



32
33
34
# File 'lib/ua/util.rb', line 32

def app
  render :app
end

#define_context(name, &block) ⇒ Object



27
28
29
30
# File 'lib/ua/util.rb', line 27

def define_context(name, &block)
  app = Ua::Application.top.app
  app.context @obj.prototype, name, &block 
end

#render(ctxt = Ua::Application.top.context) ⇒ Object



36
37
38
# File 'lib/ua/util.rb', line 36

def render(ctxt = Ua::Application.top.context)
  context(@obj, ctxt)
end