class DataObj

Public Class Methods

new() click to toggle source

DataObj

Scoped variables for feeding a Liquid parsing operation

# File lib/liquidoc.rb, line 713
def initialize
  @data = {"vars" => {}}
end

Public Instance Methods

add_data!(scope="", data) click to toggle source
# File lib/liquidoc.rb, line 717
def add_data! scope="", data
  # Merges data into existing scope or creates a new scope
  if scope.empty? # store new object at root of this object
    self.data.merge!data
  else # store new object as a subordinate, named object
    if self.data.key?(scope) # merge into existing key
      self.data[scope].merge!data
    else # create a new key named after the scope
      scoped_hash = { scope => data }
      self.data.merge!scoped_hash
    end
  end
end
data() click to toggle source
# File lib/liquidoc.rb, line 731
def data
  @data
end
remove_scope(scope) click to toggle source
# File lib/liquidoc.rb, line 735
def remove_scope scope
  self.data.delete(scope)
end