Sha256: 85f5a01e39706307d51f572f8d25252eb3eeeed7abf357af43048917b677328c

Contents?: true

Size: 887 Bytes

Versions: 42

Compression:

Stored size: 887 Bytes

Contents

class Radiant::AdminUI::RegionSet

  def initialize
    @regions = Hash.new do |h,k|
      h[k] = []
    end
    yield self if block_given?
  end
  
  def [](region)
    @regions[region.to_sym]
  end
  
  def add(region=nil, partial=nil, options={})
    raise ArgumentError, "You must specify a region and a partial" unless region and partial
    if options[:before]
      index = @regions[region].empty? ? 0 : (@regions[region].index(options[:before]) || @regions[region].size)
      self[region].insert(index, partial)
    elsif options[:after]
      index = @regions[region].empty? ? 0 : (@regions[region].index(options[:after]) || @regions[region].size - 1)
      self[region].insert(index + 1, partial)
    else
      self[region] << partial
    end
  end
  
  def method_missing(method, *args, &block)
    if args.empty?
      self[method]
    else
      super
    end
  end
  
end

Version data entries

42 entries across 42 versions & 4 rubygems

Version Path
radiantcms-couchrest_model-0.1.9 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.8 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.7 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.6 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.5 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.4 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.3 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.2 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1.1 lib/radiant/admin_ui/region_set.rb
radiantcms-couchrest_model-0.1 lib/radiant/admin_ui/region_set.rb
radiant-0.7.2 lib/radiant/admin_ui/region_set.rb
radiant-0.9.1 lib/radiant/admin_ui/region_set.rb
radiant-0.8.2 lib/radiant/admin_ui/region_set.rb
radiant-0.9.0.rc2 lib/radiant/admin_ui/region_set.rb
radiant-rc-0.9.0 lib/radiant/admin_ui/region_set.rb
radiant-0.8.1 lib/radiant/admin_ui/region_set.rb
radiant-0.6.7 lib/radiant/admin_ui/region_set.rb
radiant-0.6.8 lib/radiant/admin_ui/region_set.rb
radiant-0.6.9 lib/radiant/admin_ui/region_set.rb
radiant-0.7.0 lib/radiant/admin_ui/region_set.rb