Class: Orange::AdminResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/orange-more/administration/resources/admin_resource.rb

Overview

Admin resource is a resource to help in building administration panels.

Instance Method Summary collapse

Instance Method Details



9
10
11
12
13
14
15
16
17
# File 'lib/orange-more/administration/resources/admin_resource.rb', line 9

def add_link(section, *args)
  opts = args.extract_with_defaults(:position => 0)
  @links[section] = [] unless @links.has_key?(section)
  matches = @links[section].select{|i| i[:resource] == opts[:resource] && i[:text] == opts[:text]}
  return @links[section] unless matches.empty?
  @links[section].insert(opts.delete(:position), opts)
  @links[section].compact!
  @links[section].uniq!
end

#afterLoadObject



5
6
7
# File 'lib/orange-more/administration/resources/admin_resource.rb', line 5

def afterLoad
  @links = {}
end


19
20
21
22
23
24
25
# File 'lib/orange-more/administration/resources/admin_resource.rb', line 19

def links(packet)
  @links.each do |k,section|
    section.each {|link| 
      link[:href] = orange[:mapper].route_to(packet, link[:resource], link[:resource_args])
    }
  end
end