class Arrays::HashHelper

Public Class Methods

get_hash(context, hash_name, create) click to toggle source
# File lib/liquid-arrays/hash_helper.rb, line 3
def self.get_hash(context, hash_name, create)
  unless hash_name.nil?
    if context.key?(hash_name)
      hash = context[hash_name]
    elsif create
      hash = context.scopes.last[hash_name] ||= {}
    end
  else
    if context.key?('block_hash')
      hash = context['block_hash']
    end
  end
  hash.is_a?(Hash) ? hash : nil
end