Class: Orange::SparklesResource

Inherits:
ModelResource
  • Object
show all
Extended by:
ClassInheritableAttributes
Defined in:
lib/orange-sparkles/sparkles_resource.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.auto_sitemap!Object



10
11
12
# File 'lib/orange-sparkles/sparkles_resource.rb', line 10

def self.auto_sitemap!
  self.auto_sitemap = true
end

.tab(text = nil) ⇒ Object



6
7
8
# File 'lib/orange-sparkles/sparkles_resource.rb', line 6

def self.tab(text = nil)
  self.tabbed = text
end

Instance Method Details

#do_route(packet, opts = {}) ⇒ Object



42
43
44
45
46
# File 'lib/orange-sparkles/sparkles_resource.rb', line 42

def do_route(packet, opts = {})
  resource_path = packet['route.resource_path']
  parts = resource_path.split('/')
  route(packet, parts, opts = {})
end

#exposed?(packet) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/orange-sparkles/sparkles_resource.rb', line 14

def exposed?(packet)
  []
end

#route(packet, route_parts, opts = {}) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/orange-sparkles/sparkles_resource.rb', line 48

def route(packet, route_parts, opts = {})
  if route_parts.blank?
    list(packet, opts)
  else
    show(packet, opts.with_defaults({:resource_id => route_parts.first}))
  end
end

#route_with_resource(packet, *args) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/orange-sparkles/sparkles_resource.rb', line 34

def route_with_resource(packet, *args)
  route = orange[:sitemap, true].url_for(packet,
    :resource => @my_orange_name, 
    :resource_action => :do_route
    )
  route + args.compact.join('/')
end

#stack_initObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/orange-sparkles/sparkles_resource.rb', line 18

def stack_init
  orange[:sparkles].add_tab(@my_orange_name, self.class.tabbed) if self.class.tabbed || (self.class.tabbed == nil)    
  orange.register(:sitemap_created) do |opts|
    packet = opts[:packet]
    site_id = opts[:site_id]
    orange[:sitemap, true].add_route_for(packet,
      :orange_site_id => site_id, 
      :resource => @my_orange_name, 
      :resource_action => :do_route,
      :slug => @my_orange_name.to_s, 
      :link_text => @my_orange_name.to_s.capitalize,
      :show_in_nav => true
      )
  end if (self.class.auto_sitemap || (self.class.auto_sitemap == nil)) 
end