lib/osheet/template_set.rb in osheet-0.5.0 vs lib/osheet/template_set.rb in osheet-0.6.0

- old
+ new

@@ -1,25 +1,19 @@ +require 'osheet/partial_set' require 'osheet/template' module Osheet - class TemplateSet < ::Hash + class TemplateSet < PartialSet - # this class is a Hash that behaves kinda like a set. I want to - # push templates into the set using the '<<' operator, only allow - # Osheet::Template objs to be pushed, and then be able to reference - # a particular set of templates using a key + # this class is a PartialSet that keys off of the template element + # and name. Only Osheet::Template objs can be pushed, and you reference + # a particular template using a key of def initialize super end - def <<(template) - if (key = verify(template)) - push(key, template) - end - end - # return the template set for the named element def get(element, name) lookup(key(element.to_s, name.to_s)) end @@ -49,9 +43,9 @@ def template_key(template) key(template.element, template.name) end def key(element, name) - [element, name] + [element.to_s, name.to_s] end end end