Class: Orange::Mapper

Inherits:
Resource show all
Defined in:
lib/orange-core/resources/mapper.rb

Instance Method Summary collapse

Methods inherited from Resource

call_me, #do_view, #find_extras, #init, #initialize, #nests, #options, #orange, #orange_name, #routable, #set_orange, set_orange, #view, #view_opts, #viewable, viewable

Methods included from ClassInheritableAttributes

#cattr_accessor, #cattr_reader, #cattr_writer, eval_in_accessor_module, fetch_value, store_value

Constructor Details

This class inherits a constructor from Orange::Resource

Instance Method Details

#afterLoadObject

Takes a packet extracts request information, then calls packet.route



6
7
8
# File 'lib/orange-core/resources/mapper.rb', line 6

def afterLoad
  orange.add_pulp Pulp::Packet_Mapper
end

#root_url(packet) ⇒ Object



10
11
12
13
14
# File 'lib/orange-core/resources/mapper.rb', line 10

def root_url(packet)
  root = ''
  root += packet['route.root_dir'].gsub(/\/$/,'') if packet['route.root_dir']
  root += '/'
end

#route_to(packet, resource, *args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/orange-core/resources/mapper.rb', line 16

def route_to(packet, resource, *args)
  opts = args.extract_options!
  packet = DefaultHash.new unless packet 
  context = opts[:context]
  context = packet['route.context', nil] unless (context || (packet['route.context'] == :live))
  site = packet['route.faked_site'] ? packet['route.site_url', nil] : nil
  args.unshift(resource)
  args.unshift(context)
  args.unshift(site)
  orange.fire(:route_extras, packet, args)
  root_url(packet) + args.compact.join('/')
end