Sha256: 8f7a34350db9a1e5a8b556b39b4fe167473f51ca42a0acd67632f098f93c26f8

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require 'ixtlan/babel/context'
module Ixtlan
  module Babel
    class FilterConfig
      
      private

      def context
        @context ||= {}
      end

      def context_options( context_or_options )
        if context_or_options
          case context_or_options
          when Symbol  
            if opts = context[ context_or_options ]
              opts.dup
            end
          when Hash
            context_or_options
          end
        end
      end

      public

      def default_context_key( single = :single, 
                               collection = :collection )
        @single, @collection = single, collection
      end

      def []=( key, options )
        context[ key.to_sym ] = options if key
      end

      def []( key )
        context[ key.to_sym ] if key
      end

      def single_options( context_or_options )
        context_options( context_or_options ) || context[default_context_key[0]] || {}
      end

      def collection_options( context_or_options )
        context_options( context_or_options ) || context[default_context_key[1]] || {}
      end

      attr_accessor :root

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ixtlan-babel-0.2.0 lib/ixtlan/babel/filter_config.rb