+(add)
click to toggle source
def +(add)
if add.is_a? Array
add.each {|x| self << x}
else
self << add
end
self
end
compact()
click to toggle source
Calls superclass method
def compact
Container.new + super
end
for_district(uuid)
click to toggle source
def for_district(uuid)
Container.new + select {|sugg| sugg.district_uuid == uuid}
end
for_general()
click to toggle source
def for_general
for_scope("general")
end
for_profile(profile)
click to toggle source
def for_profile(profile)
Container.new + select {|sugg| sugg.profile == profile}
end
for_scope(scope, filter = nil)
click to toggle source
def for_scope(scope, filter = nil)
VALID_SCOPES.include?(scope) || raise("invalid scope: #{scope}")
c = Container.new + select {|sugg| sugg.scope == scope}
return c if filter.nil?
case scope
when "profile"; c.for_profile(filter)
when "district"; c.for_district(filter)
else; c
end
end
group_by_class()
click to toggle source
def group_by_class
inject(Hash.new) {|h,sugg| (h[sugg.class] ||= Container.new) << sugg; h }
end
group_by_district_uuid()
click to toggle source
def group_by_district_uuid
inject(Hash.new) {|h,sugg| (h[sugg.district_uuid] ||= Container.new) << sugg; h }
end
group_by_profile()
click to toggle source
def group_by_profile
inject(Hash.new) {|h,sugg| (h[sugg.profile] ||= Container.new) << sugg; h }
end
important(filter = true)
click to toggle source
def important(filter = true)
Container.new + select {|sugg| sugg.important? == filter}
end