Class: Orange::Slices
- Inherits:
-
Resource
- Object
- Resource
- Orange::Slices
show all
- Defined in:
- lib/orange-more/slices/resources/slices.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mode, *args) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/orange-more/slices/resources/slices.rb', line 32
def method_missing(mode, *args)
packet = args.first if args.first.kind_of? Orange::Packet
opts = args.
opts[:resource_name] = 'slices'
do_view(packet, mode, opts)
end
|
Instance Method Details
#stack_init ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/orange-more/slices/resources/slices.rb', line 4
def stack_init
orange[:radius].define_tag "slice" do |tag|
content = ''
resource = (tag.attr['resource'] || :slices).to_sym
id = tag.attr['id'] || nil
mode = (tag.attr['mode'] || tag.attr['action'] || tag.attr['chunk'] || (id ? :show : :index )).to_sym
if orange.loaded?(resource)
opts = {:attrs => tag.attr, :mode => mode}
opts.merge!(:id => id) if id
ret = orange[resource].view(tag.locals.packet, opts)
if ret.blank?
content << "resource #{resource} doesn't respond to #{mode}"
else
content << ret
end
else
content << "resource #{resource} not loaded"
end
content
end
end
|
#view(packet, *args) ⇒ Object
26
27
28
29
30
|
# File 'lib/orange-more/slices/resources/slices.rb', line 26
def view(packet, *args)
opts = args.
mode = opts[:mode] || packet['route.resource_action']
do_view(packet, mode, args.)
end
|