lib/osheet/workbook.rb in osheet-1.0.0.rc.2 vs lib/osheet/workbook.rb in osheet-1.0.0.rc.3

- old
+ new

@@ -25,31 +25,31 @@ metaclass = class << self; self; end data.each {|key, value| metaclass.class_eval { define_method(key){value} }} # setup the writer, element stack, and workbook_element writer.bind(self) if writer - set_ivar(:writer, writer) - set_ivar(:element_stack, Workbook::ElementStack.new) - set_ivar(:workbook_element, WorkbookElement.new) + @_osheet_writer = writer + @_osheet_element_stack = Workbook::ElementStack.new + @_osheet_workbook_element = WorkbookElement.new # push the workbook element onto the element stack element_stack.push(workbook) # run any instance workbook build given instance_eval(&build) if build end def writer - get_ivar(:writer) + @_osheet_writer end def element_stack - get_ivar(:element_stack) + @_osheet_element_stack end def workbook_element - get_ivar(:workbook_element) + @_osheet_workbook_element end alias_method :workbook, :workbook_element # use a mixin to define its markup handlers (templates, partials, and styles) # in your workbook scope @@ -90,29 +90,9 @@ # writers are responsible for defining what each of these methods do # and what they return [:to_s, :to_data, :to_file].each do |meth| define_method(meth) {|*args| writer.send(meth, *args) } - end - - private - - OSHEET_IVAR_NS = "_osheet_" - - def get_ivar(name) - instance_variable_get(ivar_name(name)) - end - - def set_ivar(name, value) - instance_variable_set(ivar_name(name), value) - end - - def push_ivar(name, value) - get_ivar(name) << value - end - - def ivar_name(name) - "@#{OSHEET_IVAR_NS}#{name}" end end