lib/jekyll/attendease_plugin/schedule_data_parser.rb
# Populates filter related data into session,
# from source.
Populates filter related data into session,
from source.
Populates filter related data into session from source .
def populate_session_filters!(session, source)
        filters_for_session_hash = {}
        filters.each do |filter|
          filter['filter_items'].each_with_index do |filter_item, index|
            if source['filters'].include?(filter_item['id'])
              filters_for_session_hash[filter['name']] ||= { :colour => filter['colour'], :items => [] }
              filters_for_session_hash[filter['name']][:items] << {
                'name'   => filter_item['name'],
                'colour' => filter_item['colour'],
                'index'  => index,
              }
              if event['primary_filter_id'] && event['primary_filter_id'] == filter['id']
                session['primary_filter_name'] = filter['name']
                session['primary_filter'] = filter_item['name']
              end
            end
          end
        end
        session['filters'] = filters_for_session_hash.map { |key, value| { 'name' => key, 'items' => value[:items], 'colour' => value[:colour] } }
        session['filter_tags'] = get_session_filter_tags(session['filters'])
      end
def populate_session_filters! ( session , source ) filters_for_session_hash = { } filters . each do | filter | filter [ 'filter_items' ] . each_with_index do | filter_item , index | if source [ 'filters' ] . include? ( filter_item [ 'id' ] ) filters_for_session_hash [ filter [ 'name' ] ] ||= { :colour => filter [ 'colour' ] , :items => [ ] } filters_for_session_hash [ filter [ 'name' ] ] [ :items ] << { 'name' => filter_item [ 'name' ] , 'colour' => filter_item [ 'colour' ] , 'index' => index , } if event [ 'primary_filter_id' ] && event [ 'primary_filter_id' ] == filter [ 'id' ] session [ 'primary_filter_name' ] = filter [ 'name' ] session [ 'primary_filter' ] = filter_item [ 'name' ] end end end end session [ 'filters' ] = filters_for_session_hash . map { | key , value | { 'name' => key , 'items' => value [ :items ] , 'colour' => value [ :colour ] } } session [ 'filter_tags' ] = get_session_filter_tags ( session [ 'filters' ] ) end
Populates filter related data into session,
from source.
Populates filter related data into session from source .
session
source