Sha256: e834543d8e3b68e0f0a32796690e54a805136a8403eb91c463cb8bf86c496d71
Contents?: true
Size: 889 Bytes
Versions: 1
Compression:
Stored size: 889 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 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trusty-cms-1.0.0 | lib/trusty_cms/admin_ui/region_set.rb |