Class: Orange::AdminResource

Inherits:
Resource 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

Methods inherited from Resource

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

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



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