File: lib/radiant/admin_ui/region_set.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: Radiant
  class: AdminUI
  class: RegionSet#1
inherits from
  Object ( Builtin-Module )
has properties
method: initialize #3
method: [] / 1 #10
method: add / 3 #14
method: method_missing / 3 #27

Class Hierarchy

Code

   1  class Radiant::AdminUI::RegionSet
   2 
   3    def initialize
   4      @regions = Hash.new do |h,k|
   5        h[k] = []
   6      end
   7      yield self if block_given?
   8    end
   9    
  10    def [](region)
  11      @regions[region.to_sym]
  12    end
  13    
  14    def add(region=nil, partial=nil, options={})
  15      raise ArgumentError, "You must specify a region and a partial" unless region and partial
  16      if options[:before]
  17        index = @regions[region].empty? ? 0 : (@regions[region].index(options[:before]) || @regions[region].size)
  18        self[region].insert(index, partial)
  19      elsif options[:after]
  20        index = @regions[region].empty? ? 0 : (@regions[region].index(options[:after]) || @regions[region].size - 1)
  21        self[region].insert(index + 1, partial)
  22      else
  23        self[region] << partial
  24      end
  25    end
  26    
  27    def method_missing(method, *args, &block)
  28      if args.empty?
  29        self[method]
  30      else
  31        super
  32      end
  33    end
  34    
  35  en