Sha256: 1a3e0cec96c7e31d9d4b254d1fdf4b6eb22cfb15099a6f32ef77bc78c3424b92

Contents?: true

Size: 887 Bytes

Versions: 71

Compression:

Stored size: 887 Bytes

Contents

class TrustyCms::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 && 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

71 entries across 71 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-7.0.2 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-7.0.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-7.0.0 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.3 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.2.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.2.2.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.2.0 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.1.2 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.1.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.0.5 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.0.4 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.0.3 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.0.2 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.0.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-5.6.1 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-6.0.0 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-5.6.0 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-5.5.9 lib/trusty_cms/admin_ui/region_set.rb
trusty-cms-5.5.8 lib/trusty_cms/admin_ui/region_set.rb