Sha256: 262b6e6b6460f216d623de12d605b34a47429be3e89224306cf40be5b9ebe79c
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
require 'digest/sha1' class GroupsDataset < Dataset::Base datasets = [:pages, :group_readers] datasets << :group_sites if defined? Site uses *datasets def load create_group "Normal" create_group "Special" create_group "Homed", :homepage_id => page_id(:parent) create_group "Elsewhere", :site_id => site_id(:elsewhere) if defined? Site add_pages_to_group :homed, [:parent, :childless] add_readers_to_group :homed, [:normal] add_readers_to_group :special, [:another] add_pages_to_group :special, [:news] add_readers_to_group :normal, [:normal, :inactive] end helpers do def create_group(name, att={}) group = create_record Group, name.symbolize, group_attributes(att.update(:name => name)) end def group_attributes(att={}) name = att[:name] || "A group" attributes = { :name => name, :description => "Test group" }.merge(att) attributes[:site_id] ||= site_id(:test) if defined? Site attributes end end def add_pages_to_group(g, pp) g = g.is_a?(Group) ? g : groups(g) g.pages << pp.map{|p| pages(p)} end def add_readers_to_group(g, rr) g = g.is_a?(Group) ? g : groups(g) g.readers << rr.map{|r| readers(r)} end end
Version data entries
6 entries across 6 versions & 1 rubygems